Skip to content

Commit

Permalink
update opentracer to work with 128-bit trace_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ekump committed Nov 21, 2023
1 parent 76be509 commit 4f65aba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/datadog/opentracer/text_map_propagator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def inject(span_context, carrier)
carrier[Tracing::Distributed::Datadog::ORIGIN_KEY] = digest.trace_origin
carrier[Tracing::Distributed::Datadog::PARENT_ID_KEY] = digest.span_id
carrier[Tracing::Distributed::Datadog::SAMPLING_PRIORITY_KEY] = digest.trace_sampling_priority
carrier[Tracing::Distributed::Datadog::TRACE_ID_KEY] = digest.trace_id
carrier[Tracing::Distributed::Datadog::TRACE_ID_KEY] =
Datadog::Tracing::Utils::TraceId.to_low_order(digest.trace_id)

nil
end
Expand Down
9 changes: 7 additions & 2 deletions spec/datadog/opentracer/propagation_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ def baggage_to_carrier_format(baggage)
it { expect(intermediate_datadog_trace.sampling_priority).to eq(1) }
it { expect(intermediate_datadog_trace.origin).to eq('synthetics') }
it { expect(intermediate_datadog_span.finished?).to be(true) }
it { expect(intermediate_datadog_span.trace_id).to eq(origin_datadog_span.trace_id) }

it {
expect(intermediate_datadog_span.trace_id)
.to eq(Datadog::Tracing::Utils::TraceId.to_low_order(origin_datadog_span.trace_id))
}

it { expect(intermediate_datadog_span.parent_id).to eq(origin_datadog_span.span_id) }
it { expect(@intermediate_scope.span.context.baggage).to include(baggage) }

Expand All @@ -182,7 +187,7 @@ def baggage_to_carrier_format(baggage)

it do
expect(@origin_carrier).to include(
'x-datadog-trace-id' => origin_datadog_span.trace_id,
'x-datadog-trace-id' => Datadog::Tracing::Utils::TraceId.to_low_order(origin_datadog_span.trace_id),
'x-datadog-parent-id' => origin_datadog_span.span_id,
'x-datadog-sampling-priority' => 1,
'x-datadog-origin' => 'synthetics',
Expand Down
4 changes: 3 additions & 1 deletion spec/datadog/opentracer/rack_propagator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
expect(carrier).to receive(:[]=)
.with('x-datadog-origin', origin.to_s)
expect(carrier).to receive(:[]=)
.with('x-datadog-tags', "_dd.p.key=value,_dd.p.dm=-1,_dd.p.tid=#{Datadog::Tracing::Utils::TraceId.to_high_order(trace_id).to_s(16)}")
.with('x-datadog-tags',
'_dd.p.key=value,_dd.p.dm=-1,_dd.p.tid=' +
Datadog::Tracing::Utils::TraceId.to_high_order(trace_id).to_s(16))

# Expect carrier to be set with OpenTracing baggage
baggage.each do |key, value|
Expand Down

0 comments on commit 4f65aba

Please sign in to comment.