Skip to content

Commit

Permalink
sample on trace flush
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 committed Sep 24, 2024
1 parent 1aac39b commit 4ef9fbd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/datadog/tracing/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ class Tracer
# @param default_service [String] A fallback value for {Datadog::Tracing::Span#service}, as spans without
# service are rejected
# @param enabled [Boolean] set if the tracer submits or not spans to the local agent
# @param
sampler [Datadog::Tracing::Sampler] a tracer sampler, responsible for filtering out spans when needed
# @param sampler [Datadog::Tracing::Sampler] a tracer sampler, responsible for filtering out spans when needed
# @param tags [Hash] default tags added to all spans
# @param writer [Datadog::Tracing::Writer] consumes traces returned by the provided +trace_flush+
def initialize(
Expand Down Expand Up @@ -503,7 +502,10 @@ 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?
sample(trace)
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 4ef9fbd

Please sign in to comment.