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/frontend/afe/json_rpc/serviceHandler.py b/frontend/afe/json_rpc/serviceHandler.py
index 2ecb000..52e38f8 100644
--- a/frontend/afe/json_rpc/serviceHandler.py
+++ b/frontend/afe/json_rpc/serviceHandler.py
@@ -32,7 +32,7 @@
from json import encoder
json_encoder = encoder.JSONEncoder()
-from autotest_lib.client.common_lib.cros.graphite import stats
+from autotest_lib.client.common_lib.cros.graphite import autotest_stats
json_decoder = decoder.JSONDecoder()
@@ -103,11 +103,11 @@
except KeyError:
raise BadServiceRequest(request)
- stats.Counter('rpc').increment(methName)
+ autotest_stats.Counter('rpc').increment(methName)
metadata = request.copy()
metadata['_type'] = 'rpc'
- timer = stats.Timer('rpc', metadata=metadata)
+ timer = autotest_stats.Timer('rpc', metadata=metadata)
try:
timer.start()
diff --git a/frontend/afe/rpc_interface.py b/frontend/afe/rpc_interface.py
index 7a058db..4b2e90d 100644
--- a/frontend/afe/rpc_interface.py
+++ b/frontend/afe/rpc_interface.py
@@ -35,7 +35,7 @@
from django.db.models import Count
import common
from autotest_lib.client.common_lib import priorities
-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, model_logic, model_attributes
from autotest_lib.frontend.afe import control_file, rpc_utils
from autotest_lib.frontend.afe import site_rpc_interface
@@ -45,7 +45,7 @@
from autotest_lib.server.cros.dynamic_suite import tools
-_timer = stats.Timer('rpc_interface')
+_timer = autotest_stats.Timer('rpc_interface')
def get_parameterized_autoupdate_image_url(job):
"""Get the parameterized autoupdate image url from a parameterized job."""
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index dc097b3..334340c 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -18,7 +18,7 @@
from autotest_lib.client.common_lib import priorities
from autotest_lib.client.common_lib import time_utils
from autotest_lib.client.common_lib.cros import dev_server
-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 rpc_utils
from autotest_lib.server import utils
from autotest_lib.server.cros.dynamic_suite import constants
@@ -62,9 +62,10 @@
@return the contents of the desired control file.
"""
getter = control_file_getter.DevServerGetter.create(build, ds)
- timer = stats.Timer('control_files.parse.%s.%s' %
- (ds.get_server_name(ds.url()).replace('.', '_'),
- suite_name.rsplit('.')[-1]))
+ timer = autotest_stats.Timer('control_files.parse.%s.%s' %
+ (ds.get_server_name(ds.url()
+ ).replace('.', '_'),
+ suite_name.rsplit('.')[-1]))
# Get the control file for the suite.
try:
with timer:
@@ -102,8 +103,8 @@
# components to be downloaded in the background.
ds = dev_server.ImageServer.resolve(build)
timings[constants.DOWNLOAD_STARTED_TIME] = formatted_now()
- timer = stats.Timer('control_files.stage.%s' % (
- ds.get_server_name(ds.url()).replace('.', '_')))
+ timer = autotest_stats.Timer('control_files.stage.%s' % (
+ ds.get_server_name(ds.url()).replace('.', '_')))
try:
with timer:
ds.stage_artifacts(build, ['test_suites'])
@@ -373,7 +374,7 @@
# A NOT IN query with 5000 ids took about 30ms in tests made.
# These numbers seem low enough to outweigh the disadvantages of the
# solutions described above.
- timer = stats.Timer('shard_heartbeat')
+ timer = autotest_stats.Timer('shard_heartbeat')
with timer:
shard_obj = rpc_utils.retrieve_shard(shard_hostname=shard_hostname)
rpc_utils.persist_records_sent_from_shard(shard_obj, jobs, hqes)