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