graphite: Separate out configuration from the statsd classes.
The new version of the statsd classes should be created using an instance of
the new Statsd class which sets up some defaults without having to specify
them over and over. This makes it essentially compatible with the existing
usage in autotest, but will allow chromite to configure things differently and
avoid having side effects from importing the module or global state.
BUG=chromium:446291
TEST=Ran unit tests, ran stats_es_functionaltest.py, ran the
stats_mock_unittest, ran a butterfly-paladin tryjob with --hwtest, testing by
fdeng.
DEPLOY=apache,scheduler,host-scheduler
Change-Id: I1071813db197c0e5e035b4d8db615030386f1c1c
Reviewed-on: https://chromium-review.googlesource.com/246428
Reviewed-by: Fang Deng <fdeng@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
diff --git a/scheduler/host_scheduler.py b/scheduler/host_scheduler.py
index 719b2f2..c670355 100755
--- a/scheduler/host_scheduler.py
+++ b/scheduler/host_scheduler.py
@@ -63,7 +63,7 @@
from autotest_lib.frontend import setup_django_environment
from autotest_lib.client.common_lib import global_config
-from autotest_lib.client.common_lib.cros.graphite import stats
+from autotest_lib.client.common_lib.cros.graphite import autotest_stats
from autotest_lib.scheduler import email_manager
from autotest_lib.scheduler import query_managers
from autotest_lib.scheduler import rdb_lib
@@ -102,7 +102,7 @@
"""
- _timer = stats.Timer('suite_recorder')
+ _timer = autotest_stats.Timer('suite_recorder')
def __init__(self, job_query_manager):
@@ -189,7 +189,7 @@
"""
- _timer = stats.Timer('base_host_scheduler')
+ _timer = autotest_stats.Timer('base_host_scheduler')
host_assignment = collections.namedtuple('host_assignment', ['host', 'job'])
@@ -289,7 +289,7 @@
class HostScheduler(BaseHostScheduler):
"""A scheduler capable managing host acquisition for new jobs."""
- _timer = stats.Timer('host_scheduler')
+ _timer = autotest_stats.Timer('host_scheduler')
def __init__(self):
@@ -334,9 +334,11 @@
self.schedule_host_job(acquisition.host, acquisition.job)
self._record_host_assignment(acquisition.host, acquisition.job)
new_jobs_with_hosts += 1
- stats.Gauge(key).send('new_jobs_with_hosts', new_jobs_with_hosts)
- stats.Gauge(key).send('new_jobs_without_hosts',
- len(unverified_host_jobs) - new_jobs_with_hosts)
+ autotest_stats.Gauge(key).send('new_jobs_with_hosts',
+ new_jobs_with_hosts)
+ autotest_stats.Gauge(key).send('new_jobs_without_hosts',
+ len(unverified_host_jobs) -
+ new_jobs_with_hosts)
@_timer.decorate