Skip to content

otelecho: Root spans don’t mark 4xx status codes as errors, complicating Jaeger debugging #6975

Open
@Oloruntobi1

Description

@Oloruntobi1

When debugging traces in Jaeger, HTTP 4xx status codes (e.g., 401 Unauthorized) aren’t tagged as errors in the root span, even when child spans indicate errors. This makes it hard to filter failing traces using tags={"error":"true"}.

Steps to Reproduce

  1. Send a request to an Echo endpoint (e.g., /v1/auth/login) that returns a 401 status code.
  2. Query Jaeger:
    • curl 'http://localhost:16686/api/traces?service=jaeger-nl-demo&tags={"http.method":"POST"}' → Returns the trace with http.status_code=401.
    • curl 'http://localhost:16686/api/traces?service=jaeger-nl-demo&tags={"error":"true"}' → Returns nothing because the root span lacks error=true.
  3. Check the trace:
    • Root span (/v1/auth/login): http.status_code=401, no error=true.
    • Child span (validateCredentials): error=true.

Expected Behavior

Optionally allow 4xx status codes to set otel.status_code=ERROR and error=true in the root span, so traces with application-level failures (e.g., 401) can be filtered as errors in Jaeger.

Actual Behavior

Only 5xx codes set error=true in the root span, leaving 4xx traces unfilterable as errors.

Proposed Solution

PR #6973 adds a ClientErrorsAsSpanErrors config option to otelecho middleware, enabling 4xx codes to be treated as errors when set to true. Feedback welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions