Skip to content

metrics: add missing HandlePerfEmptyData error label and initialization#4943

Open
lbcristaldo wants to merge 1 commit into
cilium:mainfrom
lbcristaldo:pr/lbcristaldo/fix-handle-perf-empty-data-metric
Open

metrics: add missing HandlePerfEmptyData error label and initialization#4943
lbcristaldo wants to merge 1 commit into
cilium:mainfrom
lbcristaldo:pr/lbcristaldo/fix-handle-perf-empty-data-metric

Conversation

@lbcristaldo
Copy link
Copy Markdown
Contributor

Description

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.

Testing

  • go test ./pkg/metrics/errormetrics/...
  • go test -race ./pkg/metrics/errormetrics/...
  • make check

Changelog

Fix missing label and initialization for HandlePerfEmptyData metric.

@lbcristaldo lbcristaldo requested a review from a team as a code owner May 1, 2026 23:01
@lbcristaldo lbcristaldo requested a review from FedeDP May 1, 2026 23:01
@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit eb9be7b
🔍 Latest deploy log https://app.netlify.com/projects/tetragon/deploys/69fa8df3074d8c0008d4b0a0
😎 Deploy Preview https://deploy-preview-4943--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@FedeDP
Copy link
Copy Markdown
Contributor

FedeDP commented May 4, 2026

Ehy thanks for this!
Can you shorten commit message?

Error: ERROR:CUSTOM: Please avoid long commit subjects (max: 75, found: 82)

Thanks!

Copy link
Copy Markdown
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

LGTM.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q: why are you using InDelta here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

@lbcristaldo lbcristaldo force-pushed the pr/lbcristaldo/fix-handle-perf-empty-data-metric branch from 9235a04 to c7d3385 Compare May 4, 2026 18:34
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

@kkourt kkourt added the release-note/bug This PR fixes an issue in a previous release of Tetragon. label May 5, 2026
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>
@lbcristaldo lbcristaldo force-pushed the pr/lbcristaldo/fix-handle-perf-empty-data-metric branch from c7d3385 to eb9be7b Compare May 6, 2026 00:40
@lbcristaldo lbcristaldo requested a review from kkourt May 6, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug This PR fixes an issue in a previous release of Tetragon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants