Skip to content

Commit

Permalink
Remove tag clean up
Browse files Browse the repository at this point in the history
Removing the _dd.span_events.has_exception tag requires to loop through
the whole chunk which is not ideal. Also:
- tag is hidden (although visible in devtools)
- indication of why the chunk was sampled if there is no error span
- error sampler can be disabled so no clean up
And while it is there, this tag could also be used at processing to
detect exception span events without even unmarshalling.
  • Loading branch information
Guillaume-Barrier committed Oct 14, 2024
1 parent 8a5fddf commit d815c6c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
8 changes: 0 additions & 8 deletions pkg/trace/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ func (a *Agent) runSamplers(now time.Time, ts *info.TagStats, pt traceutil.Proce
return true, true
}
if traceContainsError(pt.TraceChunk.Spans) {
cleanUpExceptionSpanEventTag(pt.TraceChunk.Spans)
return a.ErrorsSampler.Sample(now, pt.TraceChunk.Spans, pt.Root, pt.TracerEnv), true
}
return false, true
Expand Down Expand Up @@ -679,7 +678,6 @@ func (a *Agent) runSamplers(now time.Time, ts *info.TagStats, pt traceutil.Proce
}

if traceContainsError(pt.TraceChunk.Spans) {
cleanUpExceptionSpanEventTag(pt.TraceChunk.Spans)
return a.ErrorsSampler.Sample(now, pt.TraceChunk.Spans, pt.Root, pt.TracerEnv), true
}

Expand All @@ -706,12 +704,6 @@ func spanContainsExceptionSpanEvent(span *pb.Span) bool {
return false
}

func cleanUpExceptionSpanEventTag(trace pb.Trace) {
for _, span := range trace {
delete(span.Meta, "_dd.span_events.has_exception")
}
}

func filteredByTags(root *pb.Span, require, reject []*config.Tag, requireRegex, rejectRegex []*config.TagRegex) bool {
for _, tag := range reject {
if v, ok := root.Meta[tag.K]; ok && (tag.V == "" || v == tag.V) {
Expand Down
5 changes: 0 additions & 5 deletions pkg/trace/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,16 +1353,11 @@ func TestSampleTrace(t *testing.T) {
conf: cfg,
}
t.Run(name, func(t *testing.T) {
_, hasExceptionSpanEvent := tt.trace.TraceChunk.Spans[0].Meta["_dd.span_events.has_exception"]
keep, _ := a.traceSampling(now, info.NewReceiverStats().GetTagStats(info.Tags{}), &tt.trace)
assert.Equal(t, tt.keep, keep)
assert.Equal(t, !tt.keep, tt.trace.TraceChunk.DroppedTrace)
cfg.Features["error_rare_sample_tracer_drop"] = struct{}{}
defer delete(cfg.Features, "error_rare_sample_tracer_drop")
if hasExceptionSpanEvent {
// element was cleaned up during sampling
tt.trace.TraceChunk.Spans[0].Meta["_dd.span_events.has_exception"] = "true"
}
keep, _ = a.traceSampling(now, info.NewReceiverStats().GetTagStats(info.Tags{}), &tt.trace)
assert.Equal(t, tt.keepWithFeature, keep)
assert.Equal(t, !tt.keepWithFeature, tt.trace.TraceChunk.DroppedTrace)
Expand Down

0 comments on commit d815c6c

Please sign in to comment.