Skip to content

tracer: align go labels validation with upstream PR #1454#289

Merged
gnurizen merged 1 commit into
mainfrom
rectify-stale-go-label
Jun 2, 2026
Merged

tracer: align go labels validation with upstream PR #1454#289
gnurizen merged 1 commit into
mainfrom
rectify-stale-go-label

Conversation

@gnurizen
Copy link
Copy Markdown
Collaborator

@gnurizen gnurizen commented Jun 2, 2026

Summary

The fork merged an earlier iteration of #1454 in fork PR #278. Upstream went through additional review rounds and the version that landed on upstream main looks structurally different from what's on parca-dev/main, even though the user-visible behaviour is identical. This PR brings the fork in line with the upstream-merged shape so the next upstream merge is conflict-free.

What changed (no behaviour change):

  • Custom label validation moved from inline functions in `tracer.go` into a `customLabelValidator` type in a new `tracer/labels.go`. The Tracer struct no longer carries per-feature atomic counters — those live on the validator.
  • Type and methods are unexported and the names are generic (`customLabelValidator`, `validateKey`, `validateValue`) so non-Go custom label consumers can reuse it.
  • Validators return `([]byte, bool)` and let the caller intern, so the validator has no dependency on `libpf` string internals or `pfunsafe`.
  • `cstring` NUL-trim helper shared between `goString` and the validator.
  • Tests split: `tracer/labels_test.go` covers the validator (including drop counter increments and `getAndResetMetrics`), `tracer/string_test.go` covers only `goString`.

Metric IDs stay at the fork-specific values (`IDGoLabelsDroppedInvalidName` / `IDGoLabelsDroppedInvalidValue`) — those were already reserved past upstream's range when fork PR #278 landed, and don't need to change.

Test plan

  • `go build ./tracer/...`
  • `go test ./tracer/ -run 'TestGoString|TestCustomLabelValidator'` passes

The parca fork merged an earlier iteration of open-telemetry#1454 in fork PR #278. Upstream
went through additional review rounds that reshaped the code without changing
the user-visible behaviour:

- Pull custom label validation out of tracer.go into a customLabelValidator
  type (tracer/labels.go), so the Tracer struct no longer carries per-feature
  atomic counters. Type and methods are unexported and the name is generic
  rather than Go-specific; non-Go custom label consumers can use the same
  validator.
- Validators return ([]byte, bool) and let the caller intern, so the validator
  has no dependency on libpf string internals.
- Share the cstring NUL-trim helper between goString and the validator.
- Tests split: tracer/labels_test.go covers the validator (including drop
  counter increments and GetAndResetMetrics), tracer/string_test.go covers
  only goString.

No behaviour change vs the fork-merged version. Metric IDs remain at the
fork-specific values (IDGoLabelsDroppedInvalidName/Value), as those were
already reserved past upstream's range.
@gnurizen gnurizen merged commit 3f0a8d9 into main Jun 2, 2026
45 of 50 checks passed
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.

1 participant