fix(jaegermcp): use PutBool instead of PutStr for error attribute in …#8217
fix(jaegermcp): use PutBool instead of PutStr for error attribute in …#8217YoungHypo wants to merge 2 commits intojaegertracing:mainfrom
Conversation
…search_traces Signed-off-by: haibo <haibo942us@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Jaeger MCP’s search_traces.with_errors query construction to encode the internal error attribute as a boolean (instead of a string), aligning behavior across storage backends (notably the v2 memory store).
Changes:
- Update
search_tracesquery building to useattributes.PutBool("error", true). - Add a handler test that exercises
WithErrorsfiltering against the v2 memory store implementation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/jaeger/internal/extension/jaegermcp/internal/handlers/search_traces.go | Switches the error attribute filter from string to boolean in buildQuery. |
| cmd/jaeger/internal/extension/jaegermcp/internal/handlers/search_traces_test.go | Adds a memory-store-backed test for WithErrors filtering and imports the v2 memory store. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cmd/jaeger/internal/extension/jaegermcp/internal/handlers/search_traces.go
Show resolved
Hide resolved
cmd/jaeger/internal/extension/jaegermcp/internal/handlers/search_traces_test.go
Show resolved
Hide resolved
Signed-off-by: haibo <haibo942us@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8217 +/- ##
=======================================
Coverage 95.61% 95.61%
=======================================
Files 319 319
Lines 16793 16793
=======================================
Hits 16056 16056
Misses 582 582
Partials 155 155
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
yurishkuro
left a comment
There was a problem hiding this comment.
The UI sends all tag filters as strings today, and they are converted to Attributes object using PutStr:
jaeger/cmd/jaeger/internal/extension/jaegerquery/internal/util.go
Lines 28 to 34 in 4afa357
Why is this MCP tool need to do differently?
|
As you pointed out, existing query paths normalize tag filters to strings, for example in That means The inconsistency seems to be in the memory backend. In jaeger/internal/storage/v2/memory/tenant.go Lines 259 to 266 in 4afa357 Would you prefer the fix to be in the memory backend, by making it accept both string and boolean forms of the |
Which problem is this PR solving?
Fix
search_traces.with_errorsto encode the internalerrorquery attribute as a boolean instead of a string.The previous implementation used
attributes.PutStr("error", "true"). This caused inconsistent behavior across backends. In particular, the v2 memory backend interprets the error query attribute as a boolean flag when filtering by span status, so with_errors=true could return incorrect results.Description of the changes
search_tracesto useattributes.PutBool("error", true)TestSearchTracesHandler_Handle_WithErrorsFilter_UsingMemoryStoreto assert boolean semantics.Here is a Mermaid diagram to help explain why the current code had a bug in
TestSearchTracesHandler_Handle_WithErrorsFilter_UsingMemoryStore.sequenceDiagram participant T as Test participant H as handle() participant BQ as buildQuery() participant FT as FindTraces() participant M as memory.FindTraces() participant VS as validSpan() T->>H: handle(ctx, req, input) H->>BQ: buildQuery(input) Note over BQ: PutStr("error", "true") BQ-->>H: Attributes: {error: "true" (string)} H->>FT: FindTraces(ctx, query) FT->>M: FindTraces(ctx, query) M->>VS: validSpan(span, query) Note over VS: errAttribute.Bool() Note over VS: String.Bool() = false VS->>VS: !false && Error != Ok = true VS-->>M: return false M-->>FT: (no trace) FT-->>H: empty iterator H-->>T: output.Traces = []How was this change tested?
Checklist
make lint testAI Usage in this PR (choose one)
See AI Usage Policy.