Skip to content

Commit

Permalink
sample trace before flush unless already sampled
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 committed Sep 25, 2024
1 parent 4fff83a commit 7203b51
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/datadog/tracing/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,11 @@ def sample_span(trace_op, span)
def flush_trace(trace_op)
begin
trace = @trace_flush.consume!(trace_op)
write(trace) if trace && !trace.empty?
if trace && !trace.empty?
# check if trace is not sampled
sample_trace(trace) unless trace.sampled?
write(trace)
end
rescue StandardError => e
FLUSH_TRACE_LOG_ONLY_ONCE.run do
Datadog.logger.warn { "Failed to flush trace: #{e.class.name} #{e} at #{Array(e.backtrace).first}" }
Expand Down

0 comments on commit 7203b51

Please sign in to comment.