mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 20:51:21 -03:30
Merge pull request #11927 from fosterseth/fix_subsystem_metrics_sync_in_async
Fix subsystem metrics sync-only operation in async context
This commit is contained in:
commit
b608b73110
@ -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 = [
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user