metrics: add missing HandlePerfEmptyData error label and initialization#4943
Open
lbcristaldo wants to merge 1 commit into
Open
metrics: add missing HandlePerfEmptyData error label and initialization#4943lbcristaldo wants to merge 1 commit into
lbcristaldo wants to merge 1 commit into
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Ehy thanks for this!
Thanks! |
FedeDP
reviewed
May 4, 2026
| before := testutil.ToFloat64(GetHandlerErrors(ops.MSG_OP_EXECVE, HandlePerfEmptyData)) | ||
| HandlerErrorsInc(ops.MSG_OP_EXECVE, HandlePerfEmptyData) | ||
| after := testutil.ToFloat64(GetHandlerErrors(ops.MSG_OP_EXECVE, HandlePerfEmptyData)) | ||
| assert.InDelta(t, before+1, after, 1e-9) |
Contributor
There was a problem hiding this comment.
Q: why are you using InDelta here?
Contributor
Author
There was a problem hiding this comment.
i'm using InDelta because testifylint requires it for float64 comparisons, since prometheus counters store values as floats, using assert.Equal could lead to flaky tests due to precision issues
9235a04 to
c7d3385
Compare
kkourt
requested changes
May 5, 2026
| for opcode := range ops.OpCodeStrings { | ||
| if opcode != ops.MSG_OP_UNDEF && opcode != ops.MSG_OP_TEST { | ||
| GetHandlerErrors(opcode, HandlePerfHandlerError).Add(0) | ||
| GetHandlerErrors(opcode, HandlePerfEmptyData).Add(0) |
Contributor
There was a problem hiding this comment.
In observer.go we have:
if len(data) == 0 {
return ops.MSG_OP_UNDEF, nil, &HandlePerfError{
kind: errormetrics.HandlePerfEmptyData,
err: errors.New("empty perf data"),
opcode: ops.MSG_OP_UNDEF,
}
}Should't GetHandlerErrors(opcode, HandlePerfEmptyData).Add(0) be added for ops.MSG_OP_UNDEF as we do for HandlePerfUnknownOp?
HandlePerfEmptyData was defined and used in observer.go but was missing from eventHandlerErrorLabelValues, causing String() to return an empty label. Add the missing label and initialize the metric in InitMetrics() along with the other handler error types. Add unit tests for the new label and metric initialization. Signed-off-by: lbcristaldo <lucianacristaldo534@gmail.com>
c7d3385 to
eb9be7b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
HandlePerfEmptyDatawas defined and used inobserver.gobut was missing fromeventHandlerErrorLabelValues, causingString()to return an empty label. Add the missing label and initialize the metric inInitMetrics()along with the other handler error types.Add unit tests for the new label and metric initialization.
Testing
go test ./pkg/metrics/errormetrics/...go test -race ./pkg/metrics/errormetrics/...make checkChangelog