Skip to content

Commit

Permalink
[Monitoring] Adding build revision metric (#4428)
Browse files Browse the repository at this point in the history
### Motivation

Chrome folks want to know what build revision is being used in fuzz
task. This PR implements that.
  • Loading branch information
vitorguidi authored Nov 26, 2024
1 parent 18a9070 commit 413f9cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/clusterfuzz/_internal/build_management/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,17 @@ def _emit_build_age_metric(gcs_path):
logs.error(f'Failed to emit build age metric for {gcs_path}: {e}')


def _emit_build_revision_metric(revision):
"""Emits a gauge metric to track the build revision."""
monitoring_metrics.JOB_BUILD_REVISION.set(
revision,
labels={
'job': os.getenv('JOB_NAME'),
'platform': environment.platform(),
'task': os.getenv('TASK_NAME'),
})


def _get_build_url(bucket_path: Optional[str], revision: int,
job_type: Optional[str]):
"""Returns the GCS url for a build, given a bucket path and revision"""
Expand Down Expand Up @@ -1297,6 +1308,7 @@ def setup_regular_build(revision,

if revision == latest_revision:
_emit_build_age_metric(build_url)
_emit_build_revision_metric(revision)

# build_url points to a GCP bucket, and we're only converting it to its HTTP
# endpoint so that we can use remote unzipping.
Expand Down
11 changes: 11 additions & 0 deletions src/clusterfuzz/_internal/metrics/monitoring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
],
)

JOB_BUILD_REVISION = monitor.GaugeMetric(
'job/build_revision',
description=('Gauge for revision of trunk build '
'(grouped by job/platform/task).'),
field_spec=[
monitor.StringField('job'),
monitor.StringField('platform'),
monitor.StringField('task'),
],
)

JOB_BUILD_RETRIEVAL_TIME = monitor.CumulativeDistributionMetric(
'task/build_retrieval_time',
bucketer=monitor.GeometricBucketer(),
Expand Down

0 comments on commit 413f9cc

Please sign in to comment.