Skip to content

feat(apiv3): support query.attributes[key]=value filter in GET /api/v3/traces#8582

Closed
Pulkit7070 wants to merge 1 commit into
jaegertracing:mainfrom
Pulkit7070:feat/apiv3-findtraces-attributes
Closed

feat(apiv3): support query.attributes[key]=value filter in GET /api/v3/traces#8582
Pulkit7070 wants to merge 1 commit into
jaegertracing:mainfrom
Pulkit7070:feat/apiv3-findtraces-attributes

Conversation

@Pulkit7070

Copy link
Copy Markdown
Contributor

Which problem is this PR solving?

Closes #7594

Grafana and other clients that rely on GET /api/v3/traces for trace search have no way to filter by span attributes (tags). The gRPC FindTracesRequest already accepts a map<string,string> attributes field, but the HTTP gateway silently ignored it because the standard grpc-gateway encoding for proto map fields is unsupported by the gateway middleware.

Description of the changes

http_gateway.go

  • Add paramAttributesPrefix = "query.attributes[" constant.
  • In parseFindTracesQuery, scan all query parameters for the bracket-notation pattern query.attributes[<key>]=<value> and populate tracestore.TraceQueryParams.Attributes accordingly.
  • Import strings for the prefix/suffix check.

Clients can now pass one or more attribute filters as URL query params:

GET /api/v3/traces
  ?query.service_name=frontend
  &query.start_time_min=...
  &query.start_time_max=...
  &query.attributes[http.method]=GET
  &query.attributes[http.status_code]=200

http_gateway_test.go

  • Add TestHTTPGatewayFindTracesAttributes that sends two attribute filters and verifies the underlying FindTraces call receives the correct pcommon.Map.

How was this change tested?

go test ./cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/... \
  -run "TestHTTPGatewayFindTracesAttributes|TestHTTPGatewayFindTracesErrors|TestHTTPGatewayGetTrace" -v
go vet ./cmd/jaeger/internal/extension/jaegerquery/internal/apiv3/...

All new and existing tests pass. Pre-existing snapshot failures on Windows (CRLF/LF) are unrelated.

…i/v3/traces

The HTTP gateway's FindTraces handler initialized an empty Attributes map
but never populated it from query parameters; the grpc-gateway encoding for
proto map<string,string> fields is not supported by the upstream gateway.

Clients can now filter traces by span attributes via bracket-notation
query params, e.g. ?query.attributes[http.method]=GET matching the same
field that the gRPC FindTracesRequest already accepts.

Signed-off-by: Pulkit Saraf <prateeksaraf9@gmail.com>
Copilot AI review requested due to automatic review settings May 16, 2026 11:16
@Pulkit7070 Pulkit7070 requested a review from a team as a code owner May 16, 2026 11:16
@dosubot dosubot Bot added the enhancement label May 16, 2026
@Pulkit7070

Copy link
Copy Markdown
Contributor Author

Gentle ping - happy to address any feedback when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support parameters for attributes and limit in api/v3/traces endpoint

1 participant