Skip to content

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

Open
Goutham-Annem wants to merge 3 commits into
cortexproject:masterfrom
Goutham-Annem:fix/3016-spanlogger-error-level
Open

fix(spanlogger): set span error tag when log level is error#7685
Goutham-Annem wants to merge 3 commits into
cortexproject:masterfrom
Goutham-Annem:fix/3016-spanlogger-error-level

Conversation

@Goutham-Annem

Copy link
Copy Markdown

Summary

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

Changes

  • In Log(), scan the kvps for a level=error pair and call ext.Error.Set(s.Span, true) — consistent with how the existing Error() method behaves.
  • Added TestSpanLogger_Log_SetsErrorTagOnErrorLevel to verify the behaviour using a mock tracer span.

Test

go test ./pkg/util/spanlogger/... -v

Fixes #3016

The /ingester/flush, /ingester/shutdown, /flush, and /shutdown endpoints
previously accepted GET requests, making it possible to accidentally
trigger a destructive ingester operation by clicking a link in a browser
or by a pre-fetch proxy following links on the index page.

Changes:
- Route registration for flush/shutdown changed from ["GET","POST"] to ["POST"].
  A browser GET (or curl without -X POST) now returns 405 Method Not Allowed.
- Index page template updated to render links in the "Dangerous:" section as
  HTML <form method="POST"> submit buttons rather than plain <a href> anchors,
  preventing browser-initiated GET requests while keeping the UI functional.
- tools/migrate-ingester-statefulsets.sh updated to use `wget --post-data=""`
  (BusyBox wget supports this flag) so the script continues to work after the
  GET handler is removed.
- Two tests added/extended to assert the POST-form rendering for dangerous links.

Fixes cortexproject#3243

Signed-off-by: Goutham Annem <gouthemannem@gmail.com>
Reflects the change introduced in pkg/api/api.go that removed GET
from the allowed methods for /ingester/flush, /flush, /ingester/shutdown,
and /shutdown. Browsers and scripts must now use POST to trigger these
operations.

Signed-off-by: Goutham Annem <gouthemannem@gmail.com>
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>
@dosubot dosubot Bot added go Pull requests that update Go code type/bug type/observability To help know what is going on inside Cortex labels Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code size/M type/bug type/observability To help know what is going on inside Cortex

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