Shortcut Instance.objects.me when possible

This commit is contained in:
Alan Rominger
2022-08-18 16:01:49 -04:00
parent 03eaeac459
commit a64467c5a6
6 changed files with 29 additions and 41 deletions

View File

@@ -166,11 +166,7 @@ class Metrics:
elif settings.IS_TESTING():
self.instance_name = "awx_testing"
else:
try:
self.instance_name = Instance.objects.me().hostname
except Exception as e:
self.instance_name = settings.CLUSTER_HOST_ID
logger.info(f'Instance {self.instance_name} seems to be unregistered, error: {e}')
self.instance_name = Instance.objects.my_hostname()
# metric name, help_text
METRICSLIST = [