Skip to content

Commit

Permalink
update trace operation to take tracer for sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
ZStriker19 committed Sep 25, 2024
1 parent 7f4dceb commit e9b2cd7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/datadog/tracing/trace_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def initialize(
metrics: nil,
trace_state: nil,
trace_state_unknown_fields: nil,
remote_parent: false
remote_parent: false,
tracer: nil

)
# Attributes
@id = id || Tracing::Utils::TraceId.next_id
Expand All @@ -98,6 +100,7 @@ def initialize(
@profiling_enabled = profiling_enabled
@trace_state = trace_state
@trace_state_unknown_fields = trace_state_unknown_fields
@tracer = tracer

# Generic tags
set_tags(tags) if tags
Expand Down Expand Up @@ -291,7 +294,7 @@ def to_digest
span_id = @active_span && @active_span.id
span_id ||= @parent_span_id unless finished?
# sample the trace_operation with the tracer
tracer.sample_trace(self) unless sampled?
tracer&.sample_trace(self) unless priority_sampled?

TraceDigest.new(
span_id: span_id,
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/tracing/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,14 @@ def build_trace(digest = nil)
trace_state: digest.trace_state,
trace_state_unknown_fields: digest.trace_state_unknown_fields,
remote_parent: digest.span_remote,
tracer: self
)
else
TraceOperation.new(
hostname: hostname,
profiling_enabled: profiling_enabled,
remote_parent: false,
tracer: self
)
end
end
Expand Down

0 comments on commit e9b2cd7

Please sign in to comment.