Merge "Resolve statsd client once at startup"
This commit is contained in:
commit
ac703de734
@ -49,7 +49,8 @@ class StateMachineNodeLauncher(stats.StatsReporter):
|
||||
"""
|
||||
|
||||
def __init__(self, handler, node, provider_config):
|
||||
super().__init__()
|
||||
launcher = handler.pw.nodepool
|
||||
super().__init__(launcher.statsd)
|
||||
# Based on utils.NodeLauncher
|
||||
logger = logging.getLogger(
|
||||
f"nodepool.StateMachineNodeLauncher.{provider_config.name}")
|
||||
|
@ -51,7 +51,8 @@ class NodeLauncher(threading.Thread,
|
||||
describing the provider launching this node.
|
||||
'''
|
||||
threading.Thread.__init__(self, name="NodeLauncher-%s" % node.id)
|
||||
stats.StatsReporter.__init__(self)
|
||||
launcher = handler.pw.nodepool
|
||||
stats.StatsReporter.__init__(self, launcher.statsd)
|
||||
logger = logging.getLogger("nodepool.NodeLauncher")
|
||||
request = handler.request
|
||||
self.log = get_annotated_logger(logger,
|
||||
|
@ -79,7 +79,7 @@ class PoolWorker(threading.Thread, stats.StatsReporter):
|
||||
self.launcher_id = "%s-%s-%s" % (socket.getfqdn(),
|
||||
self.name,
|
||||
uuid.uuid4().hex)
|
||||
stats.StatsReporter.__init__(self)
|
||||
stats.StatsReporter.__init__(self, nodepool.statsd)
|
||||
|
||||
def getPriority(self):
|
||||
pool = self.getPoolConfig()
|
||||
@ -972,6 +972,7 @@ class StatsWorker(BaseCleanupWorker, stats.StatsReporter):
|
||||
self.log = logging.getLogger('nodepool.StatsWorker')
|
||||
self.stats_event = threading.Event()
|
||||
self.election = None
|
||||
stats.StatsReporter.__init__(self, nodepool.statsd)
|
||||
|
||||
def stop(self):
|
||||
self._running = False
|
||||
@ -983,8 +984,6 @@ class StatsWorker(BaseCleanupWorker, stats.StatsReporter):
|
||||
|
||||
def _run(self):
|
||||
try:
|
||||
stats.StatsReporter.__init__(self)
|
||||
|
||||
if not self._statsd:
|
||||
return
|
||||
|
||||
|
@ -50,9 +50,9 @@ class StatsReporter(object):
|
||||
'''
|
||||
Class adding statsd reporting functionality.
|
||||
'''
|
||||
def __init__(self):
|
||||
def __init__(self, statsd_client):
|
||||
super(StatsReporter, self).__init__()
|
||||
self._statsd = get_client()
|
||||
self._statsd = statsd_client
|
||||
|
||||
def recordLaunchStats(self, subkey, dt):
|
||||
'''
|
||||
|
Loading…
x
Reference in New Issue
Block a user