Skip to content

Commit

Permalink
Adding fuzzing session duration metric (#4336)
Browse files Browse the repository at this point in the history
### Motivation

We currently lack metrics for fuzzing session duration. This PR adds
that as a histogram metric, with granularity by fuzzer, job and
platform.

Part of #4271
  • Loading branch information
vitorguidi authored Oct 29, 2024
1 parent b16d752 commit 6eb6da1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/clusterfuzz/_internal/bot/tasks/utasks/fuzz_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ def do_blackbox_fuzzing(self, fuzzer, fuzzer_directory, job_type):

def run(self):
"""Run the fuzzing session."""
start_time = time.time()
# Update LSAN local blacklist with global blacklist.
global_blacklisted_functions = (
self.uworker_input.fuzz_task_input.global_blacklisted_functions)
Expand Down Expand Up @@ -1871,6 +1872,14 @@ def run(self):
self.fuzz_task_output.fuzzer_revision = self.fuzzer.revision
self.fuzz_task_output.crash_groups.extend(crash_groups)

fuzzing_session_duration = time.time() - start_time
monitoring_metrics.FUZZING_SESSION_DURATION.add(
fuzzing_session_duration, {
'fuzzer': self.fuzzer_name,
'job': self.job_type,
'platform': environment.platform()
})

return uworker_msg_pb2.Output(fuzz_task_output=self.fuzz_task_output) # pylint: disable=no-member

def postprocess(self, uworker_output):
Expand Down
13 changes: 13 additions & 0 deletions src/clusterfuzz/_internal/metrics/monitoring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@
],
)

# This metric tracks fuzzer setup and data bundle update,
# fuzzing time and the time to upload results to datastore
FUZZING_SESSION_DURATION = monitor.CumulativeDistributionMetric(
'task/fuzz/session/duration',
bucketer=monitor.FixedWidthBucketer(width=0.05, num_finite_buckets=20),
description=('Total duration of fuzzing session.'),
field_spec=[
monitor.StringField('fuzzer'),
monitor.StringField('job'),
monitor.StringField('platform'),
],
)

JOB_TOTAL_FUZZ_TIME = monitor.CounterMetric(
'task/fuzz/job/total_time',
description=('The total fuzz time in seconds '
Expand Down

0 comments on commit 6eb6da1

Please sign in to comment.