Skip to content

fix(spanlogger): set span error tag when log level is error - #7834

Open
Goutham-Annem wants to merge 1 commit into
cortexproject:masterfrom
Goutham-Annem:fix/3016-spanlogger-error-level-v2
Open

fix(spanlogger): set span error tag when log level is error#7834
Goutham-Annem wants to merge 1 commit into
cortexproject:masterfrom
Goutham-Annem:fix/3016-spanlogger-error-level-v2

Conversation

@Goutham-Annem

Copy link
Copy Markdown

What this PR does / why we need it

When SpanLogger.Log() is called with level=error in the key-value pairs, the associated OpenTracing span's error tag is not set. This means errors logged through SpanLogger are invisible as errors in tracing UIs (Jaeger, Zipkin, etc.), even though they appear correctly in structured logs.

The existing SpanLogger.Error() method does set ext.Error.Set(span, true) correctly. Log() should mirror that behaviour when it detects a level=error pair in its kvps.

Checklist

  • Tests updated / added
  • CHANGELOG entry added
  • Commits signed off (git commit -s)

Fixes #3016

Note: This PR was developed with AI assistance (Claude Code).

When SpanLogger.Log() is called with level=error in the key-value pairs,
the associated span's error tag was not being set, so errors logged through
SpanLogger were invisible as errors in tracing UIs.

Scan the kvps in Log() for a level=error pair and call ext.Error.Set when
found, consistent with the existing Error() method behaviour.

Fixes cortexproject#3016

Signed-off-by: Goutham Annem <gouthemannem@gmail.com>
@Goutham-Annem
Goutham-Annem requested a review from a team as a code owner September 9, 2026 02:13
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.

spanlogger Log should call Error if log level is error

1 participant