-
Notifications
You must be signed in to change notification settings - Fork 564
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] Extend TESTCASE_UPLOAD_TRIAGE_DURATION to account for fuzzer generated test cases #4481
Conversation
I'll let @alhijazi review this first. Let me know if you'd still like my review afterwards. |
…zzer generated test cases (#4481) [#4364](#4364) implemented the tracking for the time it takes clusterfuzz to complete several steps of the manually uploaded testcase lifecycle. As per Chrome's request, the metric will now contain an 'origin' label, which indicates if the testcase was 'manually_uploaded' or generated by a 'fuzzer'. The code was also simplified, by reusing the get_age_in_seconds method from the TestCase entity. Also, it adds the 'stuck_in_triage' boolean field to the testcase entity, to facilitate figuring out what testcases are in a stuck state, so follow up actions can be taken. Part of #4271
@@ -31,6 +31,8 @@ | |||
|
|||
|
|||
def emit_testcase_triage_duration_metric(testcase_id: int, step: str): | |||
'''Finds out if a testcase is fuzzer generated or manually uploaded, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong style docstring.
@@ -61,15 +60,30 @@ def emit_testcase_triage_duration_metric(testcase_id: int, step: str): | |||
' failed to emit TESTCASE_UPLOAD_TRIAGE_DURATION metric.') | |||
return | |||
|
|||
from_fuzzer = not get_testcase_upload_metadata(testcase_id) | |||
|
|||
assert step in [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we can throw an assertion failure if our metrics collection isn't working? I don't think this is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to removing this.
' failed to emit TESTCASE_UPLOAD_TRIAGE_DURATION metric.') | ||
return | ||
|
||
testcase_age_in_hours = testcase.get_age_in_seconds() / 3600 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: / (60 * 60)
bucketer=monitor.GeometricBucketer(), | ||
field_spec=[ | ||
monitor.StringField('step'), | ||
monitor.StringField('job'), | ||
monitor.StringField('origin'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, this can be a boolean field.
@@ -686,6 +689,8 @@ def get_created_time(self) -> ndb.DateTimeProperty: | |||
|
|||
def get_age_in_seconds(self): | |||
current_time = datetime.datetime.utcnow() | |||
if not self.get_created_time(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this check is needed since get_created_time
seems to never return None
logs.info('Emiting TESTCASE_UPLOAD_TRIAGE_DURATION metric for testcase ' | ||
f'{testcase_id} (age = {elapsed_time_since_upload}) ' | ||
f'{testcase_id} (age = {testcase_age_in_hours} hours.) ' | ||
'in step {step}.') | ||
|
||
monitoring_metrics.TESTCASE_UPLOAD_TRIAGE_DURATION.add( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of this metric is now inaccurate since it now covers both fuzzed and uploaded testcases, it needs to be changed.
Does BUG_FILING_FROM_TESTCASE_ELAPSED_TIME
cover both also?
…stuck in analyze (#4547) ### Motivation We currently have no way to tell if analyze task was successfully executed. The TESTCASE_UPLOAD_TRIAGE_DURATION metric from #4364 would only track duration for tasks that did finish. An analyze_pending field is added to the Testcase entity in datastore, which is set to False by default, to True for manually uploaded testcases, and to False once analyze task postprocess runs. It also increments the UNTRIAGED_TESTCASE_AGE metric from #4381 with a status label, so we can know at what step the testcase is stuck, thus allowing us to alert if analyze is taking longer to finish than expected. The alert itself could be, for instance, P50 age of untriaged testcase (status=analyze_pending) > 3h. Also, this retroactively addresses comments from #4481: * Fixes docstring for emit_testcase_triage_duration_metric * Removes assertions * Renames TESTCASE_UPLOAD_TRIAGE_DURATION to TESTCASE_TRIAGE_DURATION, since it now accounts for fuzzer generated testcases * Use a boolean "from_fuzzer" field, instead of "origin" string, in TESTCASE_TRIAGE_DURATION
…stuck in analyze (#4547) ### Motivation We currently have no way to tell if analyze task was successfully executed. The TESTCASE_UPLOAD_TRIAGE_DURATION metric from #4364 would only track duration for tasks that did finish. An analyze_pending field is added to the Testcase entity in datastore, which is set to False by default, to True for manually uploaded testcases, and to False once analyze task postprocess runs. It also increments the UNTRIAGED_TESTCASE_AGE metric from #4381 with a status label, so we can know at what step the testcase is stuck, thus allowing us to alert if analyze is taking longer to finish than expected. The alert itself could be, for instance, P50 age of untriaged testcase (status=analyze_pending) > 3h. Also, this retroactively addresses comments from #4481: * Fixes docstring for emit_testcase_triage_duration_metric * Removes assertions * Renames TESTCASE_UPLOAD_TRIAGE_DURATION to TESTCASE_TRIAGE_DURATION, since it now accounts for fuzzer generated testcases * Use a boolean "from_fuzzer" field, instead of "origin" string, in TESTCASE_TRIAGE_DURATION
Motivation
#4364 implemented the tracking for the time it takes clusterfuzz to complete several steps of the manually uploaded testcase lifecycle.
As per Chrome's request, the metric will now contain an 'origin' label, which indicates if the testcase was 'manually_uploaded' or generated by a 'fuzzer'.
The code was also simplified, by reusing the get_age_in_seconds method from the TestCase entity.
Also, it adds the 'stuck_in_triage' boolean field to the testcase entity, to facilitate figuring out what testcases are in a stuck state, so follow up actions can be taken.
Part of #4271