Skip to content

Use OTel Status.Code to filter error traces in search_traces#8554

Open
Sofiyan-Shaikh wants to merge 2 commits into
jaegertracing:mainfrom
Sofiyan-Shaikh:fix/search-traces-with-errors-otel-status
Open

Use OTel Status.Code to filter error traces in search_traces#8554
Sofiyan-Shaikh wants to merge 2 commits into
jaegertracing:mainfrom
Sofiyan-Shaikh:fix/search-traces-with-errors-otel-status

Conversation

@Sofiyan-Shaikh
Copy link
Copy Markdown

@Sofiyan-Shaikh Sofiyan-Shaikh commented May 11, 2026

Which problem is this PR solving?

search_traces with with_errors=true was silently missing all OTel error traces because it filtered by the legacy Jaeger v1 error=true attribute tag instead of Status.Code = Error.
issues : #8553

Description of the changes

  • Removed attributes.PutStr("error", "true") from buildQuery — the Jaeger v1 attribute tag is no longer sent to storage as a filter.
  • Added post-retrieval filtering in the handle loop: traces where no span has Status.Code = Error are skipped when with_errors=true.

How was this change tested?

  • Updated TestSearchTracesHandler_Handle_WithErrorsFilter to assert error=true attribute is no longer injected into the query, and that the handler correctly filters non-error traces out.
  • Added TestSearchTracesHandler_Handle_WithErrorsFilter_OTelStatusOnly covering the exact bug scenario — a GenAI trace with finish_reason=content_filter and Status.Code=Error but no error=true tag.
  • Existing TestSearchTracesHandler_Handle_WithErrorsFilter_UsingMemoryStore continues to pass end-to-end.

AI Usage in this PR (choose one)

See AI Usage Policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Checklist

Copilot AI review requested due to automatic review settings May 11, 2026 12:26
@Sofiyan-Shaikh Sofiyan-Shaikh requested a review from a team as a code owner May 11, 2026 12:26
@dosubot dosubot Bot added the bug label May 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes search_traces’s with_errors=true behavior for OpenTelemetry traces by filtering based on OTel span Status.Code=Error instead of the legacy Jaeger v1 error=true attribute tag, ensuring OTel error traces are no longer silently omitted.

Changes:

  • Remove injection of error=true into the storage query parameters.
  • Add post-retrieval filtering to drop traces that have no spans with Status.Code=Error when with_errors=true.
  • Update and add unit tests to validate the new filtering behavior, including the “OTel status only” bug scenario.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/jaeger/internal/extension/jaegermcp/internal/handlers/search_traces.go Moves with_errors filtering from query-time (legacy tag) to post-retrieval filtering using OTel Status.Code.
cmd/jaeger/internal/extension/jaegermcp/internal/handlers/search_traces_test.go Updates existing with_errors test expectations and adds coverage for OTel error traces without legacy error=true tags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 80 to +83
summary := buildTraceSummary(trace)
if input.WithErrors && !summary.HasErrors {
continue
}
@Sofiyan-Shaikh
Copy link
Copy Markdown
Author

Hi @yurishkuro, I've implemented the fix for OTel error filtering and added logic to expand the search depth to ensure reliable results. I'd appreciate your review when you have a moment. Thanks!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants