Skip to content

Commit

Permalink
use has_remote_parent in traceoperation to clear up confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Mar 12, 2024
1 parent 445d923 commit b308587
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions lib/datadog/tracing/trace_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TraceOperation
:rule_sample_rate,
:sample_rate,
:sampling_priority,
:is_remote
:has_remote_parent

attr_reader \
:active_span_count,
Expand Down Expand Up @@ -72,14 +72,14 @@ def initialize(
metrics: nil,
trace_state: nil,
trace_state_unknown_fields: nil,
is_remote: false
has_remote_parent: false
)
# Attributes
@id = id || Tracing::Utils::TraceId.next_id
@max_length = max_length || DEFAULT_MAX_LENGTH
@parent_span_id = parent_span_id
@sampled = sampled.nil? ? true : sampled
@is_remote = is_remote
@has_remote_parent = has_remote_parent

# Tags
@agent_sample_rate = agent_sample_rate
Expand Down Expand Up @@ -300,7 +300,7 @@ def to_digest
trace_service: service,
trace_state: @trace_state,
trace_state_unknown_fields: @trace_state_unknown_fields,
is_remote: (@is_remote && @active_span.nil?),
is_remote: (@has_remote_parent && @active_span.nil?),
).freeze
end

Expand All @@ -327,7 +327,7 @@ def fork_clone
trace_state_unknown_fields: (@trace_state_unknown_fields && @trace_state_unknown_fields.dup),
tags: meta.dup,
metrics: metrics.dup,
is_remote: @is_remote
has_remote_parent: @has_remote_parent
)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/datadog/tracing/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ def build_trace(digest = nil)
tags: digest.trace_distributed_tags,
trace_state: digest.trace_state,
trace_state_unknown_fields: digest.trace_state_unknown_fields,
is_remote: digest.is_remote,
has_remote_parent: digest.is_remote,
)
else
TraceOperation.new(
hostname: hostname,
profiling_enabled: profiling_enabled,
is_remote: false,
has_remote_parent: false,
)
end
end
Expand Down
4 changes: 2 additions & 2 deletions sig/datadog/tracing/trace_operation.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Datadog
attr_accessor rate_limiter_rate: untyped
attr_accessor rule_sample_rate: untyped
attr_accessor sample_rate: untyped
attr_accessor is_remote: untyped
attr_accessor has_remote_parent: untyped
attr_accessor sampling_priority: untyped
attr_reader active_span_count: untyped
attr_reader active_span: untyped
Expand All @@ -23,7 +23,7 @@ module Datadog
attr_writer sampled: untyped
attr_writer service: untyped

def initialize: (?agent_sample_rate: untyped?, ?events: untyped?, ?hostname: untyped?, ?id: untyped?, ?max_length: untyped, ?name: untyped?, ?origin: untyped?, ?parent_span_id: untyped?, ?rate_limiter_rate: untyped?, ?resource: untyped?, ?rule_sample_rate: untyped?, ?sample_rate: untyped?, ?sampled: untyped?, ?sampling_priority: untyped?, ?service: untyped?, ?tags: untyped?, ?metrics: untyped?, ?is_remote: untyped?) -> void
def initialize: (?agent_sample_rate: untyped?, ?events: untyped?, ?hostname: untyped?, ?id: untyped?, ?max_length: untyped, ?name: untyped?, ?origin: untyped?, ?parent_span_id: untyped?, ?rate_limiter_rate: untyped?, ?resource: untyped?, ?rule_sample_rate: untyped?, ?sample_rate: untyped?, ?sampled: untyped?, ?sampling_priority: untyped?, ?service: untyped?, ?tags: untyped?, ?metrics: untyped?, ?has_remote_parent: untyped?) -> void
def full?: () -> untyped
def finished_span_count: () -> untyped
def finished?: () -> untyped
Expand Down
24 changes: 12 additions & 12 deletions spec/datadog/tracing/trace_operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
metrics: metrics,
trace_state: trace_state,
trace_state_unknown_fields: trace_state_unknown_fields,
is_remote: is_remote,
has_remote_parent: has_remote_parent,
}
end

Expand All @@ -60,7 +60,7 @@
let(:trace_state_unknown_fields) { 'any;field;really' }

let(:distributed_tags) { { '_dd.p.test' => 'value' } }
let(:is_remote) { true }
let(:has_remote_parent) { true }
end

shared_examples 'a span with default events' do
Expand Down Expand Up @@ -88,7 +88,7 @@
service: nil,
trace_state: nil,
trace_state_unknown_fields: nil,
is_remote: false,
has_remote_parent: false,
)
end

Expand Down Expand Up @@ -185,11 +185,11 @@
it { expect(trace_op.parent_span_id).to eq(parent_span_id) }
end

context ':is_remote' do
subject(:options) { { is_remote: true } }
let(:is_remote) { true }
context ':has_remote_parent' do
subject(:options) { { has_remote_parent: true } }
let(:has_remote_parent) { true }

it { expect(trace_op.is_remote).to eq(is_remote) }
it { expect(trace_op.has_remote_parent).to eq(has_remote_parent) }
end

context ':rate_limiter_rate' do
Expand Down Expand Up @@ -1857,11 +1857,11 @@ def span
end
end

context 'and :is_remote is set to false' do
let(:options) { { is_remote: is_remote } }
let(:is_remote) { false }
context 'and :has_remote_parent is set to false' do
let(:options) { { has_remote_parent: has_remote_parent } }
let(:has_remote_parent) { false }

it { expect(digest.is_remote).to eq(is_remote) }
it { expect(digest.is_remote).to eq(false) }
end

context 'but :parent_span_id has been defined' do
Expand Down Expand Up @@ -2106,7 +2106,7 @@ def span
sampled?: sampled,
sampling_priority: sampling_priority,
service: be_a_copy_of(service),
is_remote: true,
has_remote_parent: true,
)
end

Expand Down

0 comments on commit b308587

Please sign in to comment.