Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitoring] Adding a build age metric #4341

Merged
merged 22 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Using correct env var JOB_NAME instead of JOB_TYPE
  • Loading branch information
vitorguidi committed Oct 22, 2024
commit eb60e754a164c01011ee1d2368028ddbbb5d825a
15 changes: 8 additions & 7 deletions src/clusterfuzz/_internal/build_management/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,18 @@ def _emmit_build_age_metric(self, gcs_path):
# the gcs api returns string, and the local filesystem implementation
# returns a datetime.datetime object normalized for UTC
vitorguidi marked this conversation as resolved.
Show resolved Hide resolved
last_update_time = datetime.datetime.fromisoformat(last_update_time)
now = last_update_time = datetime.datetime.now(datetime.timezone.utc)
now = datetime.datetime.now(datetime.timezone.utc)
elapsed_time = now - last_update_time
elapsed_time_in_hours = elapsed_time.total_seconds() / 3600
# Fuzz targets do not apply for custom builds
fuzz_target = self.fuzz_target if self.fuzz_target is not None else 'N/A'
vitorguidi marked this conversation as resolved.
Show resolved Hide resolved
monitoring_metrics.JOB_BUILD_AGE.add(
elapsed_time_in_hours, {
'fuzz_target': fuzz_target,
'job_type': os.getenv('JOB_TYPE'),
'platform': environment.platform(),
})
labels = {
'fuzz_target': fuzz_target,
'job_type': os.getenv('JOB_NAME'),
'platform': environment.platform(),
'task': os.getenv('TASK_NAME'),
}
monitoring_metrics.JOB_BUILD_AGE.add(elapsed_time_in_hours, labels)
# This field is expected as a datetime object
# https://cloud.google.com/storage/docs/json_api/v1/objects#resource
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions src/clusterfuzz/_internal/metrics/monitoring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
monitor.StringField('fuzz_target'),
vitorguidi marked this conversation as resolved.
Show resolved Hide resolved
monitor.StringField('job_type'),
monitor.StringField('platform'),
monitor.StringField('task'),
],
)

Expand Down
Loading