Skip to content

Commit 413f9cc

Browse files
authored
[Monitoring] Adding build revision metric (#4428)
### Motivation Chrome folks want to know what build revision is being used in fuzz task. This PR implements that.
1 parent 18a9070 commit 413f9cc

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/clusterfuzz/_internal/build_management/build_manager.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,17 @@ def _emit_build_age_metric(gcs_path):
12271227
logs.error(f'Failed to emit build age metric for {gcs_path}: {e}')
12281228

12291229

1230+
def _emit_build_revision_metric(revision):
1231+
"""Emits a gauge metric to track the build revision."""
1232+
monitoring_metrics.JOB_BUILD_REVISION.set(
1233+
revision,
1234+
labels={
1235+
'job': os.getenv('JOB_NAME'),
1236+
'platform': environment.platform(),
1237+
'task': os.getenv('TASK_NAME'),
1238+
})
1239+
1240+
12301241
def _get_build_url(bucket_path: Optional[str], revision: int,
12311242
job_type: Optional[str]):
12321243
"""Returns the GCS url for a build, given a bucket path and revision"""
@@ -1297,6 +1308,7 @@ def setup_regular_build(revision,
12971308

12981309
if revision == latest_revision:
12991310
_emit_build_age_metric(build_url)
1311+
_emit_build_revision_metric(revision)
13001312

13011313
# build_url points to a GCP bucket, and we're only converting it to its HTTP
13021314
# endpoint so that we can use remote unzipping.

src/clusterfuzz/_internal/metrics/monitoring_metrics.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@
4444
],
4545
)
4646

47+
JOB_BUILD_REVISION = monitor.GaugeMetric(
48+
'job/build_revision',
49+
description=('Gauge for revision of trunk build '
50+
'(grouped by job/platform/task).'),
51+
field_spec=[
52+
monitor.StringField('job'),
53+
monitor.StringField('platform'),
54+
monitor.StringField('task'),
55+
],
56+
)
57+
4758
JOB_BUILD_RETRIEVAL_TIME = monitor.CumulativeDistributionMetric(
4859
'task/build_retrieval_time',
4960
bucketer=monitor.GeometricBucketer(),

0 commit comments

Comments
 (0)