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 metric for task outcome #4458

Merged
merged 13 commits into from
Dec 10, 2024

Conversation

vitorguidi
Copy link
Collaborator

@vitorguidi vitorguidi commented Nov 27, 2024

Motivation

We currently have no metric that tracks the error rate for each task. This PR implements that, and the error rate can be obtained by summing up the metric with outcome=failure, divided by the overall sum.

This is useful for SLI alerting.

Part of #4271

Copy link
Collaborator

@jonathanmetzman jonathanmetzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utask_main is run with utasks.uworker_bot_main You might want to catch this too.

src/clusterfuzz/_internal/bot/tasks/commands.py Outdated Show resolved Hide resolved
@vitorguidi vitorguidi force-pushed the feature/task-error-rate branch from 872273a to 53cdc9e Compare December 9, 2024 04:45
Copy link
Collaborator

@jonathanmetzman jonathanmetzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

# failure.
outcome = 'error' if _exc_type or self.saw_failure else 'success'
monitoring_metrics.TASK_OUTCOME_COUNT.increment({
**self._labels, 'outcome': outcome
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a nice enum of possible errors, I'd much rather we be more specific here and record it as the outcome: e.g. result: 'NO_ERROR' or result: 'BUILD_SETUP_FAILED'. It would greatly help in debugging problems.

Exceptions can be bucketed as their own result: 'UNHANDLED_EXCEPTION'.

Do you think it will pose a problem with metric cardinality?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm now that I think of it, we should get rid of job

For oss fuzz:

15 tasks
1300 projects ~ 1300 jobs
3 subtasks (pre main post)
2 modes (batch/queue)
3 platforms (linux mac win)
2 outcomes (fail/success)

This goes for around 700k, which will bite us. We could swap job out for all outcomes, and that will be around ~16k possible label combinations, which should be fine. Wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonathanmetzman the current state of the subtask duration metric allows for around 350k different label combinations, GCP's recommendation is at most 30k. Should we get rid of job in this context manager as a whole?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the limit? I think there's other things that can be removed

  1. I think modes is definitely not needed, the two modes won't live side by side much longer.
  2. I think platform may be unneeded, it can be obtained through the job name.
    Would reducing cardinality by 6X help?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there's currently about 1000 platforms in oss-fuzz but that is going away. Will that help?

Copy link
Collaborator Author

@vitorguidi vitorguidi Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is actually 40 distinct values under that enum.
15 tasks * 40 outcomes * 1300 jobs * 3 subtasks > 1M, so yeah, no chance at all to get the discriminated outcomes, while keeping jobs.

Another option is to spin a separate metric, TASK_OUTCOME_BY_ERROR_TYPE, for which we track all the labels except job, and manage to stay under 30k distinct labels.

Wdyt @letitz

As far as converting the proto value to a name goes, it can be done like this:

uworker_msg_pb2.ErrorType.Name(uworker_msg_pb2.ErrorType.NO_ERROR)
'NO_ERROR'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry why 40 outcomes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

38 ErrorTypes from the utask_main output, 'N/A' (to indicate no error), and 'UNHANDLED_EXCEPTION', as suggested by titouan

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIne with me to have a separate metric for error types that does not group by job.

I think modes is definitely not needed, the two modes won't live side by side much longer.
I think platform may be unneeded, it can be obtained through the job name.
Would reducing cardinality by 6X help?

Mode does not contribute much to cardinality since we have a mostly static mapping from (task, platform) to mode. Platform is actually free since as you point out, it is implied by job. So there are not 3 copies of each job, one for each platform. IIRC this is what actually matters, not the potential cardinality if we generated all possible labels.

src/clusterfuzz/_internal/bot/tasks/utasks/__init__.py Outdated Show resolved Hide resolved
@vitorguidi vitorguidi requested a review from letitz December 10, 2024 00:12
@vitorguidi
Copy link
Collaborator Author

Motivation

We currently have no metric that tracks the error rate for each task. This PR implements that, and the error rate can be obtained by summing up the metric with outcome=failure, divided by the overall sum.

This is useful for SLI alerting.

Part of #4271

Merging this for the sake of quick iteration, we can revisit this if folks feel like it is necessary

@vitorguidi vitorguidi merged commit 514cec0 into master Dec 10, 2024
7 checks passed
@vitorguidi vitorguidi deleted the feature/task-error-rate branch December 10, 2024 23:44
vitorguidi added a commit that referenced this pull request Dec 11, 2024
### Motivation

We currently have no metric that tracks the error rate for each task.
This PR implements that, and the error rate can be obtained by summing
up the metric with outcome=failure, divided by the overall sum.

This is useful for SLI alerting.

Part of #4271
vitorguidi added a commit that referenced this pull request Dec 11, 2024
### Motivation

This merges #4489, #4458 and #4483 to the chrome temporary deployment
branch

The purpose is to have task error rate metrics, and log what old
testcases are polluting the testcase upload metrics, so we can figure
out if a purge is necessary

---------

Co-authored-by: jonathanmetzman <[email protected]>
@jonathanmetzman
Copy link
Collaborator

I think this metric needs some temporary reworking.
image
As is, it's not very useful because it is too close to 100% error rate because ClusterFuzz is treating expected misbehavior (bad builds) as exceptional when they are not.
I think until ClusterFuzz is refactored, this metric would be more useful if it only measured exceptions and not handled errors.

@letitz
Copy link
Collaborator

letitz commented Dec 12, 2024

It may not be useful for alerting, but I for one find this data interesting. I would not have assumed that most tasks would end in "temporary failure".

Maybe that's the breakdown we want though here? "success", "temporary error"/"retry" and "failure"?

@vitorguidi
Copy link
Collaborator Author

vitorguidi commented Dec 12, 2024

This is too complex IMO, I agree with Jonathan's approach of only considering UNHANDLED_EXCEPTION as failure.
We can probably get rid of outcome and only emit this 'error_condition' type, which will be there for analysis when we are troubleshooting.

Breaking down by success/retry/failure is too janky, as we would have to map these 38 ErrorType enums to 3 sets, leading to polluting the codebase and make things hard to understand. Also, for every new ErrorType added, this metric would have to be updated, adding further friction to development.

I would much rather treat only UNHANDLED_EXCEPTION as an error, since it will not lead to false positives, and simplify things.

@letitz
Copy link
Collaborator

letitz commented Dec 12, 2024

Breaking down by success/retry/failure is too janky, as we would have to map these 38 ErrorType enums to 3 sets, which would lead to polluting the codebase and make things hard to understand. Also, for every new ErrorType added, this metric would have to be updated, adding further friction to development.

I would have thought the opposite. Right now, if I want to know what it means for regression task to fail with REGRESSION_NO_CRASH, then I have to go read the code. If I could see easily that a certain error just means we'll retry the task, I would find the codebase easier to reason through. That said, this reminds me that errors don't map cleanly to retrying or not, such as when we notice a flake and might or might not retry depending on whether it's a first offense.

Ultimately I would like to know when there are jobs whose tasks are failing too often, so I can go investigate.

@vitorguidi
Copy link
Collaborator Author

vitorguidi commented Dec 12, 2024

Breaking down by success/retry/failure is too janky, as we would have to map these 38 ErrorType enums to 3 sets, which would lead to polluting the codebase and make things hard to understand. Also, for every new ErrorType added, this metric would have to be updated, adding further friction to development.

I would have thought the opposite. Right now, if I want to know what it means for regression task to fail with REGRESSION_NO_CRASH, then I have to go read the code. If I could see easily that a certain error just means we'll retry the task, I would find the codebase easier to reason through. That said, this reminds me that errors don't map cleanly to retrying or not, such as when we notice a flake and might or might not retry depending on whether it's a first offense.

Ultimately I would like to know when there are jobs whose tasks are failing too often, so I can go investigate.

We can partition these errors on a best effort basis in three sets:

  • things that unequivocally imply success (ie, NO_ERROR and ANALYZE_DOES_NOT_REPRODUCE),
  • things for which there MIGHT BE a retry (ie, PROGRESSION_TIMEOUT, MINIMIZE_DEADLINE_EXCEEDED),
  • things that unequivocally imply failure (ie, FUZZ_DATA_BUNDLE_SETUP_FAILURE, unhandled exceptions).

The above would belong in the TASK_OUTCOME_COUNT, under the 'outcome' label:

  • success
  • potential_retry
  • failure

Wdyt? This solves the problem, it will at least be possible to filter for the unambiguous failures, and those will be the jobs to be further drilled down.

@letitz
Copy link
Collaborator

letitz commented Dec 12, 2024

Fine with me! @alhijazi might still want to have a say

@vitorguidi
Copy link
Collaborator Author

vitorguidi commented Dec 13, 2024

Fine with me! @alhijazi might still want to have a say

Given the 30k different label limitation, we will not be able to drill down by ErrorType and job simultaneously:

  • 38 error types + 'N/A' + 'UNHANDLED_EXCEPTION' as error_count
  • 1300+ jobs in oss-fuzz

52k>30k, so this is as far as we can go. Restating: drilling down per job and ErrorType is an impossible requirement.

vitorguidi added a commit that referenced this pull request Dec 16, 2024
…ss, maybe_retry and failure outcomes (#4499)

### Motivation

#4458 implemented a task outcome metric, so we can track error rates in
utasks, by job/task/subtask.

As failures are expected for ClusterFuzz, initially only unhandled
exceptions would be considered as actual errors. Chrome folks asked for
a better partitioning of error codes, which is implemented here as the
following outcomes:

* success: the task has unequivocally succeeded, producing a sane result
* maybe_retry: some transient error happened, and the task is
potentially being retried. This might capture some unretriable failure
condition, but it is a compromise we are willing to make in order to
decrease false positives.
* failure: the task has unequivocally failed.

Part of #4271
vitorguidi added a commit that referenced this pull request Dec 16, 2024
…ss, maybe_retry and failure outcomes (#4499)

### Motivation

#4458 implemented a task outcome metric, so we can track error rates in
utasks, by job/task/subtask.

As failures are expected for ClusterFuzz, initially only unhandled
exceptions would be considered as actual errors. Chrome folks asked for
a better partitioning of error codes, which is implemented here as the
following outcomes:

* success: the task has unequivocally succeeded, producing a sane result
* maybe_retry: some transient error happened, and the task is
potentially being retried. This might capture some unretriable failure
condition, but it is a compromise we are willing to make in order to
decrease false positives.
* failure: the task has unequivocally failed.

Part of #4271
@alhijazi
Copy link
Collaborator

Fine with me! @alhijazi might still want to have a say

Fine with me also!

vitorguidi added a commit that referenced this pull request Dec 23, 2024
#4516)

### Motivation

#4458 implemented an error rate for utasks, only considering exceptions.
In #4499 , outcomes were split between success, failure and maybe_retry
conditions. There we learned that the volume of retryable outcomes is
negligible, so it makes sense to count them as failures.

Listing out all the success conditions under _MetricRecorder is not
desirable. However, we are consciously taking this technical debt so we
can deliver #4271 .

A refactor of uworker main will be later performed, so we can split the
success and failure conditions, both of which are mixed in
uworker_output.ErrorType.

Reference for tech debt acknowledgement: #4517
vitorguidi added a commit that referenced this pull request Dec 26, 2024
#4516)

### Motivation

#4458 implemented an error rate for utasks, only considering exceptions.
In #4499 , outcomes were split between success, failure and maybe_retry
conditions. There we learned that the volume of retryable outcomes is
negligible, so it makes sense to count them as failures.

Listing out all the success conditions under _MetricRecorder is not
desirable. However, we are consciously taking this technical debt so we
can deliver #4271 .

A refactor of uworker main will be later performed, so we can split the
success and failure conditions, both of which are mixed in
uworker_output.ErrorType.

Reference for tech debt acknowledgement: #4517
vitorguidi added a commit that referenced this pull request Dec 27, 2024
#4516)

### Motivation

#4458 implemented an error rate for utasks, only considering exceptions.
In #4499 , outcomes were split between success, failure and maybe_retry
conditions. There we learned that the volume of retryable outcomes is
negligible, so it makes sense to count them as failures.

Listing out all the success conditions under _MetricRecorder is not
desirable. However, we are consciously taking this technical debt so we
can deliver #4271 .

A refactor of uworker main will be later performed, so we can split the
success and failure conditions, both of which are mixed in
uworker_output.ErrorType.

Reference for tech debt acknowledgement: #4517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants