Skip to content

Commit

Permalink
Adding build revision metric
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorguidi committed Nov 22, 2024
1 parent c46d537 commit e9200f6
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 @@ -1226,6 +1226,16 @@ def _emit_build_age_metric(gcs_path):
except Exception as e:
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]):
Expand Down Expand Up @@ -1298,6 +1308,8 @@ 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.
http_build_url = build_url.replace('gs://', 'https://storage.googleapis.com/')
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_age',
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.FixedWidthBucketer(width=0.05, num_finite_buckets=20),
Expand Down

0 comments on commit e9200f6

Please sign in to comment.