diff options
author | Seth Foster <fosterseth@users.noreply.github.com> | 2022-03-22 16:55:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 16:55:05 +0100 |
commit | b608b73110bd069cdc784adc73aa478b3f8f1132 (patch) | |
tree | ee811377cdd8b7ea73314b57f99e9a9cfa05c175 | |
parent | Merge pull request #11748 from john-westcott-iv/github_workflows_on_all_releases (diff) | |
parent | Fix sync-only operation in async context (diff) | |
download | awx-b608b73110bd069cdc784adc73aa478b3f8f1132.tar.xz awx-b608b73110bd069cdc784adc73aa478b3f8f1132.zip |
Merge pull request #11927 from fosterseth/fix_subsystem_metrics_sync_in_async
Fix subsystem metrics sync-only operation in async context
-rw-r--r-- | awx/main/analytics/subsystem_metrics.py | 7 | ||||
-rw-r--r-- | awx/main/wsbroadcast.py | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/awx/main/analytics/subsystem_metrics.py b/awx/main/analytics/subsystem_metrics.py index 2e4c8b41c7..a08211b311 100644 --- a/awx/main/analytics/subsystem_metrics.py +++ b/awx/main/analytics/subsystem_metrics.py @@ -136,7 +136,7 @@ class HistogramM(BaseM): class Metrics: - def __init__(self, auto_pipe_execute=True): + def __init__(self, auto_pipe_execute=True, instance_name=None): self.pipe = redis.Redis.from_url(settings.BROKER_URL).pipeline() self.conn = redis.Redis.from_url(settings.BROKER_URL) self.last_pipe_execute = time.time() @@ -150,7 +150,10 @@ class Metrics: # the calling function should call .pipe_execute() explicitly self.auto_pipe_execute = auto_pipe_execute Instance = apps.get_model('main', 'Instance') - self.instance_name = Instance.objects.me().hostname + if instance_name: + self.instance_name = instance_name + else: + self.instance_name = Instance.objects.me().hostname # metric name, help_text METRICSLIST = [ diff --git a/awx/main/wsbroadcast.py b/awx/main/wsbroadcast.py index 47006adc9d..9ed7b47848 100644 --- a/awx/main/wsbroadcast.py +++ b/awx/main/wsbroadcast.py @@ -71,7 +71,7 @@ class WebsocketTask: self.protocol = protocol self.verify_ssl = verify_ssl self.channel_layer = None - self.subsystem_metrics = s_metrics.Metrics() + self.subsystem_metrics = s_metrics.Metrics(instance_name=name) async def run_loop(self, websocket: aiohttp.ClientWebSocketResponse): raise RuntimeError("Implement me") |