Extend TraceRedactor interface and add ErrTraceHidden - #6811
Conversation
0b62d10 to
bee854b
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces two main enhancements: (1) extends the frontend TraceRedactor hook to return errors (including a sentinel ErrTraceHidden to translate to 404/NotFound), and (2) adds a typed “extensions” mechanism to the per-tenant overrides configuration with registry-backed validation and legacy flat-key compatibility.
Changes:
- Update
TraceRedactor.RedactTraceAttributesto returnerror, addErrTraceHidden, and translate it to HTTP 404 / gRPC NotFound in combiners. - Add an overrides extension registry (
RegisterExtension) plus decoding/validation logic for YAML/JSON and legacy flat-key conversion. - Update config/runtime-config unmarshalling behavior to properly distinguish new-format extension errors vs legacy fallback, and add extensive tests for overrides extensions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/overrides/runtime_config_overrides.go | Adjust legacy-fallback logic to avoid swallowing extension-related errors. |
| modules/overrides/extension.go | Introduce extension registry + typed decode/validate + legacy flat-key processing. |
| modules/overrides/extension_test.go | Add coverage for extension registration, JSON/YAML marshal/unmarshal, and legacy conversions. |
| modules/overrides/config.go | Add Overrides.Extensions support; JSON/YAML marshal/unmarshal hooks; legacy fallback adjustments. |
| modules/overrides/config_legacy.go | Add LegacyOverrides.Extensions and JSON/YAML flattening/unflattening for legacy wire format. |
| modules/overrides/config_test.go | Update config tag tests and field-population helper for new Extensions field. |
| modules/frontend/combiner/common.go | Add ErrTraceHidden, update TraceRedactor interface, and map hidden traces to NotFound. |
| modules/frontend/combiner/trace_by_id.go | Handle ErrTraceHidden as HTTP 404 for v1 trace-by-id responses. |
| modules/frontend/combiner/trace_by_id_v2.go | Propagate redactor errors so genericCombiner can translate ErrTraceHidden. |
| CHANGELOG.md | Add changelog entry for overrides extension mechanism. |
bee854b to
cb2600e
Compare
73b201c to
f19bbf0
Compare
| err := c.traceRedactor.RedactTraceAttributes(traceResult) | ||
| if err != nil { | ||
| if errors.Is(err, ErrTraceHidden) { | ||
| return &http.Response{ | ||
| StatusCode: http.StatusNotFound, | ||
| Body: http.NoBody, | ||
| Header: http.Header{}, | ||
| }, nil | ||
| } |
There was a problem hiding this comment.
When ErrTraceHidden is returned, HTTPFinal returns a 404 response but doesn't update the combiner's internal c.code / c.statusMessage. That means StatusCode() can still report 200 after a hidden-trace response, which is inconsistent with genericCombiner (it sets httpStatusCode = 404) and may confuse any callers relying on StatusCode() for metrics/control flow. Consider setting c.code = http.StatusNotFound (and clearing c.statusMessage) before returning the 404 response here.
* Add ErrTraceHidden to combiner and handle it correctly * Reuse ErrTraceHidden text * Use http.NoBody for empty responses * Set internal httpStatusCode consistently in combiner
What this PR does:
The method
TraceRedactor.RedactTraceAttributes()can now return an error. When the error isErrTraceHidden, this signals that the trace should not be returned. Endpoints should return 404 (not found) instead.This allows
TraceRedactorimplementation to support a wider range of redaction modes.Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]