-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix(memory): accept string-form error filters in trace search #8217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2da7a1d
61a51b0
271b35b
0c0afb3
4247cbd
37edd99
223f28b
4d2f672
600299e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import ( | |
|
|
||
| "github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegermcp/internal/types" | ||
| "github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerquery/querysvc" | ||
| "github.com/jaegertracing/jaeger/internal/storage/v2/memory" | ||
| ) | ||
|
|
||
| // mockQueryService and createTestTrace are defined in test_helpers.go | ||
|
|
@@ -160,9 +161,9 @@ func TestSearchTracesHandler_Handle_WithErrorsFilter(t *testing.T) { | |
| mock := &mockQueryService{ | ||
| findTracesFunc: func(_ context.Context, query querysvc.TraceQueryParams) iter.Seq2[[]ptrace.Traces, error] { | ||
| // Verify that error attribute filter is added | ||
| val, ok := query.Attributes.Get("error") | ||
| errorAttr, ok := query.Attributes.Get("error") | ||
| assert.True(t, ok) | ||
| assert.Equal(t, "true", val.Str()) | ||
| assert.Equal(t, "true", errorAttr.Str()) | ||
|
|
||
| return func(yield func([]ptrace.Traces, error) bool) { | ||
| // Return only error traces (simulating storage filtering) | ||
|
|
@@ -187,6 +188,44 @@ func TestSearchTracesHandler_Handle_WithErrorsFilter(t *testing.T) { | |
| assert.True(t, output.Traces[0].HasErrors) | ||
| } | ||
|
|
||
| func TestSearchTracesHandler_Handle_WithErrorsFilter_UsingMemoryStore(t *testing.T) { | ||
| store, err := memory.NewStore(memory.Configuration{MaxTraces: 10}) | ||
| require.NoError(t, err) | ||
|
|
||
| require.NoError(t, store.WriteTraces(context.Background(), createTestTrace( | ||
| "trace111", | ||
| "test", | ||
| "/ok", | ||
| false, | ||
| ))) | ||
| require.NoError(t, store.WriteTraces(context.Background(), createTestTrace( | ||
| "trace222", | ||
| "test", | ||
| "/error", | ||
| true, | ||
| ))) | ||
|
|
||
| handler := &searchTracesHandler{ | ||
| queryService: querysvc.NewQueryService(store, store, querysvc.QueryServiceOptions{}), | ||
| maxResults: 100, | ||
| } | ||
|
|
||
| input := types.SearchTracesInput{ | ||
| StartTimeMin: "-1h", | ||
| ServiceName: "test", | ||
| WithErrors: true, | ||
| } | ||
|
|
||
| _, output, err := handler.handle(context.Background(), &mcp.CallToolRequest{}, input) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Len(t, output.Traces, 1) | ||
| assert.True(t, output.Traces[0].HasErrors) | ||
| assert.Equal(t, "test", output.Traces[0].RootService) | ||
| assert.Equal(t, "/error", output.Traces[0].RootSpanName) | ||
| assert.Empty(t, output.Error) | ||
|
yurishkuro marked this conversation as resolved.
|
||
| } | ||
|
Comment on lines
+191
to
+227
|
||
|
|
||
| func TestSearchTracesHandler_Handle_SearchDepthDefault(t *testing.T) { | ||
| testTrace := createTestTrace("trace444", "test", "/test", false) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test still asserts the
errorquery attribute is a string (errorAttr.Str() == "true"). Per the PR intent (and to avoid backend-specific behavior), theerrorattribute should be encoded as a boolean. Update the assertion to require a boolean type/value (e.g.,errorAttr.Type() == pcommon.ValueTypeBoolanderrorAttr.Bool() == true), and ensure the handler builds the query accordingly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree. This 271b35b reverts the error attribute from bool to string. The errorQueryValue() function in tenant.go adds backward compatibility to handle both types. The test correctly asserts string type.