Skip to content

fix: add logging to ES TraceWriter for silent write failures#8237

Open
majiayu000 wants to merge 5 commits intojaegertracing:mainfrom
majiayu000:fix/issue-8058-archive-write-es
Open

fix: add logging to ES TraceWriter for silent write failures#8237
majiayu000 wants to merge 5 commits intojaegertracing:mainfrom
majiayu000:fix/issue-8058-archive-write-es

Conversation

@majiayu000
Copy link
Copy Markdown

Summary

  • Add logger to TraceWriter struct using existing Logger from SpanWriterParams
  • Log a warning when ToDBModel returns 0 spans from non-empty trace data, making silent archive write failures diagnosable
  • Log a debug message on successful span writes to ES
  • Add test for empty traces case (WriteTraces with zero ResourceSpans)

Fixes #8058

Test plan

  • New TestTraceWriter_WriteTraces_EmptyTraces test verifies behavior with empty traces
  • Existing TestTraceWriter_WriteTraces updated to include logger
  • go test ./internal/storage/v2/elasticsearch/tracestore/... — all pass
  • make fmt — clean
  • make lint — 0 issues
  • Full test suite (go test -race ./...) — all pass

The ES TraceWriter.WriteTraces() had no logging, making it impossible
to diagnose cases where archive writes silently produced no spans.
Add a warning log when ToDBModel returns zero spans and a debug log
for successful writes.

Fixes jaegertracing#8058

Signed-off-by: majiayu000 <1835304752@qq.com>
Copilot AI review requested due to automatic review settings March 23, 2026 15:35
@majiayu000 majiayu000 requested a review from a team as a code owner March 23, 2026 15:35
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

This PR improves diagnosability of Elasticsearch trace archive writes by adding structured logging to the v2 ES TraceWriter when trace conversion produces no spans and when span writes succeed.

Changes:

  • Add a logger field to TraceWriter (wired from SpanWriterParams.Logger).
  • Emit a warning when ToDBModel produces zero DB spans, and a debug log when spans are written.
  • Update and extend unit tests, including a new empty-traces test case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/storage/v2/elasticsearch/tracestore/writer.go Adds logger to TraceWriter and logs on zero-span conversion / successful writes.
internal/storage/v2/elasticsearch/tracestore/writer_test.go Updates tests to construct TraceWriter with a logger and adds an empty-traces test.

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

Add observability to the archive trace flow to help diagnose issues
like jaegertracing#8058 where writes to Elasticsearch are silently dropped.

- TraceWriter.WriteTraces: distinguish empty input (Debug) from
  non-empty trace data that produced zero spans after conversion (Warn)
- QueryService.ArchiveTrace: log request received, completion, and
  failure with trace_id for end-to-end traceability
- Pass logger from telemetry to QueryServiceOptions

Signed-off-by: majiayu000 <1835304752@qq.com>
Add nil check for p.Logger in NewTraceWriter, defaulting to
zap.NewNop() to prevent nil-pointer panics when callers pass
telemetry.Settings{} with a nil Logger.

Signed-off-by: majiayu000 <1835304752@qq.com>
- Return early before calling ToDBModel for truly empty traces
- Add scope_spans and spans counts to the warning log for better debugging
- Use zaptest/observer assertions for all log paths in tests

Signed-off-by: majiayu000 <1835304752@qq.com>
Copilot AI review requested due to automatic review settings March 23, 2026 16:06
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


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

When p.Logger is nil, NewTraceWriter defaulted to zap.NewNop() for its
own logger but still passed the original nil p.Logger to
spanstore.NewSpanWriter, which could cause nil-pointer panics. Now
p.Logger is also updated before constructing the inner SpanWriter.

Signed-off-by: majiayu000 <1835304752@qq.com>
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.

[Bug]: Archive trace returns 200 but does not write to Elasticsearch

2 participants