Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Jun 5, 2024
1 parent 66e5b96 commit d9cf13c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/datadog/tracing/span_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def build_span
metrics: Core::Utils::SafeDup.frozen_or_dup(metrics),
parent_id: @parent_id,
resource: @resource,
service: @service,
service: @service || @parent&.service,
start_time: @start_time,
status: @status,
type: @type,
Expand Down
7 changes: 5 additions & 2 deletions lib/datadog/tracing/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def build_trace(digest = nil)
id: digest.trace_id,
origin: digest.trace_origin,
parent_span_id: digest.span_id,
service: @default_service,
sampling_priority: digest.trace_sampling_priority,
# Distributed tags are just regular trace tags with special meaning to Datadog
tags: digest.trace_distributed_tags,
Expand All @@ -332,6 +333,7 @@ def build_trace(digest = nil)
TraceOperation.new(
hostname: hostname,
profiling_enabled: profiling_enabled,
service: @default_service,
remote_parent: false,
)
end
Expand All @@ -341,12 +343,13 @@ def bind_trace_events!(trace_op)
events = trace_op.send(:events)

events.span_before_start.subscribe do |event_span_op, event_trace_op|
event_trace_op.service ||= @default_service
event_span_op.service ||= @default_service
sample_trace(event_trace_op) if event_span_op && event_span_op.parent_id == 0
end

events.span_finished.subscribe do |event_span, event_trace_op|
# Fallback in case the service was never set
event_span.service ||= @default_service

sample_span(event_trace_op, event_span)
flush_trace(event_trace_op)
end
Expand Down

0 comments on commit d9cf13c

Please sign in to comment.