[V8] Remove ability to customize send_ts_mon_values' parameter --target-type
This parameter can only take values 'task' and 'device'. The latter is useful
when monitoring physical devices, which is unlikely to be done from recipes,
thus we simply hard-code 'task' value. Should such a need arise in the future,
the API of this method can be extended to support customizing target_type and/or
many other parameters that can be passed to send_ts_mon_values.
This also improves argument documentation and renames the send_value method to
send_counter_value as there are other types of metrics supported by the
underlying script, e.g. float, gauge etc.
TBR=tmrts@chromium.org,ddoman@chromium.org,nodir@chromium.org
Change-Id: I56e535a82dd681417295effd8db5b0e6a29e56f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/build/+/1688796
Commit-Queue: Sergiy Belozorov <sergiyb@chromium.org>
Reviewed-by: Sergiy Belozorov <sergiyb@chromium.org>
diff --git a/scripts/slave/README.recipes.md b/scripts/slave/README.recipes.md
index 38f9fb2..1f4f588 100644
--- a/scripts/slave/README.recipes.md
+++ b/scripts/slave/README.recipes.md
@@ -3412,11 +3412,13 @@
#### **class [TSMonApi](/scripts/slave/recipe_modules/ts_mon/api.py#14)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
-— **def [send\_value](/scripts/slave/recipe_modules/ts_mon/api.py#31)(self, name, value, fields=None, service_name='luci', job_name='recipe', target=None, step_name='upload ts_mon metrics'):**
+— **def [send\_counter\_value](/scripts/slave/recipe_modules/ts_mon/api.py#31)(self, name, value, fields=None, service_name='luci', job_name='recipe', step_name='upload ts_mon metrics'):**
Sends a value to the ts_mon monitoring service.
-Based on https://cs.chromium.org/chromium/infra/infra/tools/send_ts_mon_values/.
+Based on the ts_mon monitoring pipeline and script for sending data to it:
+https://cs.chromium.org/chromium/infra/infra/tools/send_ts_mon_values/.
+Internal users can read more about ts_mon at go/brown-bag-timeseries-basics.
Note that the candinality of all possible combinations of different values
passed to fields should be less than 5000, i.e. do not use unique
@@ -3440,9 +3442,8 @@
/chrome/infra, i.e. /foo/bar will become /chrome/infra/foo/bar.
value: The value to be reported.
fields: Dictionary with fields to be associated with the value.
- service_name: Name of the ts_mon service.
- job_name: Name of the ts_mon job.
- target: Target reporting the value, defaults to the current hostname.
+ service_name: Name of the service being monitored.
+ job_name: Name of this job instance of the task.
step_name: Name of the step sending information to ts_mon.
### *recipe_modules* / [v8](/scripts/slave/recipe_modules/v8)
diff --git a/scripts/slave/recipe_modules/ts_mon/api.py b/scripts/slave/recipe_modules/ts_mon/api.py
index eea89f2..fdb1635 100644
--- a/scripts/slave/recipe_modules/ts_mon/api.py
+++ b/scripts/slave/recipe_modules/ts_mon/api.py
@@ -28,9 +28,8 @@
self.m.cipd.EnsureFile().add_package(
'infra/infra_python/${platform}', 'latest'))
- def send_value(self, name, value, fields=None, service_name='luci',
- job_name='recipe', target=None,
- step_name='upload ts_mon metrics'):
+ def send_counter_value(self, name, value, fields=None, service_name='luci',
+ job_name='recipe', step_name='upload ts_mon metrics'):
"""Sends a value to the ts_mon monitoring service.
Based on the ts_mon monitoring pipeline and script for sending data to it:
@@ -59,9 +58,8 @@
/chrome/infra, i.e. /foo/bar will become /chrome/infra/foo/bar.
value: The value to be reported.
fields: Dictionary with fields to be associated with the value.
- service_name: Name of the ts_mon service.
- job_name: Name of the ts_mon job.
- target: Target reporting the value, defaults to the current hostname.
+ service_name: Name of the service being monitored.
+ job_name: Name of this job instance of the task.
step_name: Name of the step sending information to ts_mon.
"""
self._ensure_infra_python()
@@ -69,15 +67,9 @@
counter_config = {'name': name, 'value': value}
counter_config.update(fields or {})
- if target is None:
- if self._test_data.enabled:
- target = 'fake-hostname'
- else: # pragma: no cover
- target = socket.gethostname()
-
result = self.m.python(step_name, self._infra_python_path.join('run.py'), [
SEND_TS_MON_VALUES,
- '--ts-mon-target-type', target,
+ '--ts-mon-target-type', 'task',
'--ts-mon-task-service-name', service_name,
'--ts-mon-task-job-name', job_name,
'--counter-file', self.m.json.input(counter_config),
diff --git a/scripts/slave/recipe_modules/ts_mon/tests/example.expected/basic.json b/scripts/slave/recipe_modules/ts_mon/tests/example.expected/basic.json
index 1d4de59..b39b1c2 100644
--- a/scripts/slave/recipe_modules/ts_mon/tests/example.expected/basic.json
+++ b/scripts/slave/recipe_modules/ts_mon/tests/example.expected/basic.json
@@ -32,7 +32,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "fake-hostname",
+ "task",
"--ts-mon-task-service-name",
"luci",
"--ts-mon-task-job-name",
@@ -56,7 +56,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "example_target",
+ "task",
"--ts-mon-task-service-name",
"example_service",
"--ts-mon-task-job-name",
diff --git a/scripts/slave/recipe_modules/ts_mon/tests/example.py b/scripts/slave/recipe_modules/ts_mon/tests/example.py
index 9abe6b6..e6896de 100644
--- a/scripts/slave/recipe_modules/ts_mon/tests/example.py
+++ b/scripts/slave/recipe_modules/ts_mon/tests/example.py
@@ -8,14 +8,13 @@
def RunSteps(api):
- api.ts_mon.send_value('/example/metric', 42)
- api.ts_mon.send_value(
+ api.ts_mon.send_counter_value('/example/metric', 42)
+ api.ts_mon.send_counter_value(
name='/example/metric',
value=42,
fields={'foo': 'bar'},
service_name='example_service',
job_name='example_job',
- target='example_target',
step_name='custom upload step name')
diff --git a/scripts/slave/recipes/v8/auto_roll_deps.expected/active_roll.json b/scripts/slave/recipes/v8/auto_roll_deps.expected/active_roll.json
index ecc5a15..435c00b 100644
--- a/scripts/slave/recipes/v8/auto_roll_deps.expected/active_roll.json
+++ b/scripts/slave/recipes/v8/auto_roll_deps.expected/active_roll.json
@@ -116,7 +116,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "fake-hostname",
+ "task",
"--ts-mon-task-service-name",
"auto-roll",
"--ts-mon-task-job-name",
diff --git a/scripts/slave/recipes/v8/auto_roll_deps.expected/inconsistent_state.json b/scripts/slave/recipes/v8/auto_roll_deps.expected/inconsistent_state.json
index c21a940..d814f9c 100644
--- a/scripts/slave/recipes/v8/auto_roll_deps.expected/inconsistent_state.json
+++ b/scripts/slave/recipes/v8/auto_roll_deps.expected/inconsistent_state.json
@@ -304,7 +304,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "fake-hostname",
+ "task",
"--ts-mon-task-service-name",
"auto-roll",
"--ts-mon-task-job-name",
diff --git a/scripts/slave/recipes/v8/auto_roll_deps.expected/rolling_deactivated.json b/scripts/slave/recipes/v8/auto_roll_deps.expected/rolling_deactivated.json
index c6fe196..e41928b 100644
--- a/scripts/slave/recipes/v8/auto_roll_deps.expected/rolling_deactivated.json
+++ b/scripts/slave/recipes/v8/auto_roll_deps.expected/rolling_deactivated.json
@@ -51,7 +51,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "fake-hostname",
+ "task",
"--ts-mon-task-service-name",
"auto-roll",
"--ts-mon-task-job-name",
diff --git a/scripts/slave/recipes/v8/auto_roll_deps.expected/stale_roll.json b/scripts/slave/recipes/v8/auto_roll_deps.expected/stale_roll.json
index da93e13..3a560aa 100644
--- a/scripts/slave/recipes/v8/auto_roll_deps.expected/stale_roll.json
+++ b/scripts/slave/recipes/v8/auto_roll_deps.expected/stale_roll.json
@@ -312,7 +312,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "fake-hostname",
+ "task",
"--ts-mon-task-service-name",
"auto-roll",
"--ts-mon-task-job-name",
diff --git a/scripts/slave/recipes/v8/auto_roll_deps.expected/standard.json b/scripts/slave/recipes/v8/auto_roll_deps.expected/standard.json
index d196d84..1a81a1d 100644
--- a/scripts/slave/recipes/v8/auto_roll_deps.expected/standard.json
+++ b/scripts/slave/recipes/v8/auto_roll_deps.expected/standard.json
@@ -323,7 +323,7 @@
"[CACHE]/infra-python/run.py",
"infra.tools.send_ts_mon_values",
"--ts-mon-target-type",
- "fake-hostname",
+ "task",
"--ts-mon-task-service-name",
"auto-roll",
"--ts-mon-task-job-name",
diff --git a/scripts/slave/recipes/v8/auto_roll_deps.py b/scripts/slave/recipes/v8/auto_roll_deps.py
index d37e972..62cdfef 100644
--- a/scripts/slave/recipes/v8/auto_roll_deps.py
+++ b/scripts/slave/recipes/v8/auto_roll_deps.py
@@ -170,7 +170,7 @@
monitoring_state = result.json.output['monitoring_state']
finally:
if not api.runtime.is_experimental:
- api.ts_mon.send_value(
+ api.ts_mon.send_counter_value(
name='/v8/autoroller/count',
value=1,
fields={'project': 'v8-roll', 'result': monitoring_state},