Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic caused by race condition when accessing span attributes #12661

Merged
merged 6 commits into from
Aug 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update comment
Signed-off-by: albertteoh <[email protected]>
  • Loading branch information
albertteoh committed Aug 2, 2022
commit af3dc8fb56a23be29095185302ea487a4e792de8
13 changes: 2 additions & 11 deletions processor/spanmetricsprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,7 @@ func (p *processorImp) Capabilities() consumer.Capabilities {
// It aggregates the trace data to generate metrics, forwarding these metrics to the discovered metrics exporter.
// The original input trace data will be forwarded to the next consumer, unmodified.
func (p *processorImp) ConsumeTraces(ctx context.Context, traces ptrace.Traces) error {
// Execute trace to metrics aggregation as a goroutine and only log errors instead
// of failing the entire pipeline to prioritize the propagation of trace data,
// regardless of error.
//
// This processor should be treated as a branched, out-of-band process
// that should not interfere with the flow of trace data because
// it is an orthogonal concern to the trace flow (it should not impact
// upstream or downstream pipeline trace components).

// Forward trace data unmodified.
// Forward trace data unmodified and propagate both metrics and trace pipeline errors, if any.
return multierr.Combine(p.tracesToMetrics(ctx, traces), p.nextConsumer.ConsumeTraces(ctx, traces))
}

Expand All @@ -241,7 +232,7 @@ func (p *processorImp) tracesToMetrics(ctx context.Context, traces ptrace.Traces
m, err := p.buildMetrics()

// Exemplars are only relevant to this batch of traces, so must be cleared within the lock,
// regardless of error while building metrics, before the next batch is received.
// regardless of error while building metrics, before the next batch of spans is received.
p.resetExemplarData()

// This component no longer needs to read the metrics once built, so it is safe to unlock.
Expand Down