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/monitor_db.py b/scheduler/monitor_db.py
index 3be9eb0..59af937 100755
--- a/scheduler/monitor_db.py
+++ b/scheduler/monitor_db.py
@@ -21,7 +21,7 @@
from autotest_lib.client.common_lib import global_config
from autotest_lib.client.common_lib import utils
-from autotest_lib.client.common_lib.cros.graphite import stats
+from autotest_lib.client.common_lib.cros.graphite import autotest_stats
from autotest_lib.frontend.afe import models, rpc_utils
from autotest_lib.scheduler import agent_task, drone_manager
from autotest_lib.scheduler import email_manager, gc_stats, host_scheduler
@@ -317,7 +317,7 @@
major step begins so we can try to figure out where we are using most
of the tick time.
"""
- timer = stats.Timer('scheduler.tick')
+ timer = autotest_stats.Timer('scheduler.tick')
self._log_tick_msg('Calling new tick, starting garbage collection().')
self._garbage_collection()
self._log_tick_msg('Calling _drone_manager.trigger_refresh().')
@@ -483,7 +483,7 @@
status_list = ','.join("'%s'" % status for status in statuses)
queue_entries = scheduler_models.HostQueueEntry.fetch(
where='status IN (%s)' % status_list)
- stats.Gauge('scheduler.jobs_per_tick').send(
+ autotest_stats.Gauge('scheduler.jobs_per_tick').send(
'running', len(queue_entries))
agent_tasks = []
@@ -801,7 +801,7 @@
host_jobs.append(queue_entry)
new_jobs_need_hosts = new_jobs_need_hosts + 1
- stats.Gauge(key).send('new_hostless_jobs', new_hostless_jobs)
+ autotest_stats.Gauge(key).send('new_hostless_jobs', new_hostless_jobs)
if not host_jobs:
return
if not _inline_host_acquisition:
@@ -816,9 +816,11 @@
self._schedule_host_job(host_assignment.host, host_assignment.job)
new_jobs_with_hosts = 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',
- new_jobs_need_hosts - 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',
+ new_jobs_need_hosts -
+ new_jobs_with_hosts)
def _schedule_running_host_queue_entries(self):
@@ -1008,9 +1010,9 @@
num_finished_this_cycle += agent.task.num_processes
self._log_extra_msg("Agent finished")
self.remove_agent(agent)
- stats.Gauge('scheduler.jobs_per_tick').send(
+ autotest_stats.Gauge('scheduler.jobs_per_tick').send(
'agents_started', num_started_this_cycle)
- stats.Gauge('scheduler.jobs_per_tick').send(
+ autotest_stats.Gauge('scheduler.jobs_per_tick').send(
'agents_finished', num_finished_this_cycle)
logging.info('%d running processes. %d added this cycle.',
_drone_manager.total_running_processes(),