Skip to content

Commit

Permalink
Adding build download time metric
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorguidi committed Oct 21, 2024
1 parent 19b6f1e commit faa97af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/clusterfuzz/_internal/build_management/build_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from clusterfuzz._internal.google_cloud_utils import blobs
from clusterfuzz._internal.google_cloud_utils import storage
from clusterfuzz._internal.metrics import logs
from clusterfuzz._internal.metrics import monitoring_metrics
from clusterfuzz._internal.platforms import android
from clusterfuzz._internal.system import archive
from clusterfuzz._internal.system import environment
Expand Down Expand Up @@ -417,6 +418,7 @@ def _download_and_open_build_archive(self, base_build_dir: str,
Yields:
the build archive
"""
start_time = time.time()
# Download build archive locally.
build_local_archive = os.path.join(build_dir, os.path.basename(build_url))

Expand All @@ -432,6 +434,14 @@ def _download_and_open_build_archive(self, base_build_dir: str,
logs.info(f'Downloading build from {build_url} to {build_local_archive}.')
try:
storage.copy_file_from(build_url, build_local_archive)
build_download_duration = time.time() - start_time
monitoring_metrics.JOB_BUILD_RETRIEVAL_TIME.add(
build_download_duration, {
'fuzzer': self.fuzz_target,
'job': os.getenv('JOB_TYPE'),
'platform': environment.platform()
}
)
except Exception as e:
logs.error(f'Unable to download build from {build_url}: {e}')
raise
Expand Down Expand Up @@ -475,6 +485,7 @@ def _open_build_archive(self, base_build_dir: str, build_dir: str,
if not can_unzip_over_http:
return self._download_and_open_build_archive(base_build_dir, build_dir,
build_url)
# We do not emmit a metric for build download time, if using http
logs.info("Opening an archive over HTTP, skipping archive download.")
assert http_build_url
return build_archive.open_uri(http_build_url)
Expand Down
2 changes: 1 addition & 1 deletion src/clusterfuzz/_internal/metrics/monitoring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
description=('Distribution of fuzz task\'s build retrieval times. '
'(grouped by fuzzer/job)'),
field_spec=[
monitor.StringField('fuzzer'),
monitor.StringField('fuzz_target'),
monitor.StringField('job_type'),
monitor.StringField('step'),
],
Expand Down

0 comments on commit faa97af

Please sign in to comment.