Skip to content

Commit

Permalink
Replace random 64 bits trace id generation with default 128 bits in test
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Dec 12, 2023
1 parent 0fa4a67 commit d023dc4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions spec/datadog/tracing/contrib/lograge/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
version: version,
)
end
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:span_id) { Datadog::Tracing::Utils.next_id }
let(:env) { 'env' }
let(:service) { 'service' }
Expand Down Expand Up @@ -50,7 +50,7 @@
env: 'env',
service: 'service',
span_id: span_id.to_s,
trace_id: trace_id.to_s,
trace_id: low_order_trace_id(trace_id).to_s,
version: 'version'
},
ddsource: 'ruby' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end
end

let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:span_id) { Datadog::Tracing::Utils.next_id }

let(:correlation) do
Expand All @@ -71,7 +71,7 @@
expect(log_entry).to include 'Mamamia!'
expect(log_entry).to include 'original: tag'

expect(log_entry).to include trace_id.to_s
expect(log_entry).to include low_order_trace_id(trace_id).to_s
expect(log_entry).to include span_id.to_s
expect(log_entry).to include 'production'
expect(log_entry).to include 'MyService'
Expand All @@ -91,7 +91,7 @@
expect(log_entry).to include 'Mamamia!'
expect(log_entry).to include 'original: tag'

expect(log_entry).not_to include trace_id.to_s
expect(log_entry).not_to include low_order_trace_id(trace_id).to_s
expect(log_entry).not_to include span_id.to_s
expect(log_entry).not_to include 'production'
expect(log_entry).not_to include 'MyService'
Expand All @@ -111,7 +111,7 @@
expect(log_entry).to include 'Mamamia!'
expect(log_entry).to include 'original: tag'

expect(log_entry).not_to include trace_id.to_s
expect(log_entry).not_to include low_order_trace_id(trace_id).to_s
expect(log_entry).not_to include span_id.to_s
expect(log_entry).not_to include 'production'
expect(log_entry).not_to include 'MyService'
Expand All @@ -137,7 +137,7 @@
expect(log_entry).to include 'Mamamia!'
expect(log_entry).not_to include 'original: tag'

expect(log_entry).to include trace_id.to_s
expect(log_entry).to include low_order_trace_id(trace_id).to_s
expect(log_entry).to include span_id.to_s
expect(log_entry).to include 'production'
expect(log_entry).to include 'MyService'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def perform; end
end

context 'when receiving' do
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:span_id) { Datadog::Tracing::Utils.next_id }
let(:jid) { '123abc' }

Expand All @@ -78,10 +78,10 @@ def perform; end
'args' => [],
'class' => EmptyWorker.to_s,
'jid' => jid,
'x-datadog-trace-id' => trace_id.to_s,
'x-datadog-trace-id' => low_order_trace_id(trace_id).to_s,
'x-datadog-parent-id' => span_id.to_s,
'x-datadog-sampling-priority' => '2',
'x-datadog-tags' => '_dd.p.dm=-99',
'x-datadog-tags' => "_dd.p.dm=-99,_dd.p.tid=#{high_order_hex_trace_id(trace_id)}",
'x-datadog-origin' => 'my-origin'
)
)
Expand Down Expand Up @@ -153,7 +153,7 @@ def perform; end
end

context 'when receiving' do
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:span_id) { Datadog::Tracing::Utils.next_id }
let(:jid) { '123abc' }

Expand Down
12 changes: 6 additions & 6 deletions spec/datadog/tracing/correlation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
let(:span_resource) { 'SELECT * FROM users;' }
let(:span_service) { 'acme-mysql' }
let(:span_type) { 'db' }
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:trace_name) { 'rack.request' }
let(:trace_resource) { 'GET /users' }
let(:trace_service) { 'acme-api' }
Expand Down Expand Up @@ -93,7 +93,7 @@
span_resource: span_resource,
span_service: span_service,
span_type: span_type,
trace_id: trace_id,
trace_id: low_order_trace_id(trace_id),
trace_name: trace_name,
trace_resource: trace_resource,
trace_service: trace_service,
Expand Down Expand Up @@ -174,7 +174,7 @@
span_resource: span_resource,
span_service: span_service,
span_type: span_type,
trace_id: trace_id,
trace_id: low_order_trace_id(trace_id),
trace_name: trace_name,
trace_resource: trace_resource,
trace_service: trace_service,
Expand All @@ -199,7 +199,7 @@

describe '#to_h' do
context 'when given values' do
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:span_id) { Datadog::Tracing::Utils.next_id }

it 'returns a formatted hash' do
Expand All @@ -217,7 +217,7 @@
env: 'dev',
service: 'acme-api',
version: '1.0',
trace_id: trace_id.to_s,
trace_id: low_order_trace_id(trace_id).to_s,
span_id: span_id.to_s
},
ddsource: 'ruby'
Expand Down Expand Up @@ -266,7 +266,7 @@
)
end

let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
let(:span_id) { Datadog::Tracing::Utils.next_id }
let(:env) { 'dev' }
let(:service) { 'acme-api' }
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/tracing/span_operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
end

context 'that is an Integer' do
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }
it { is_expected.to have_attributes(trace_id: trace_id) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/tracing/trace_digest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

context ':trace_id' do
let(:options) { { trace_id: trace_id } }
let(:trace_id) { Datadog::Tracing::Utils.next_id }
let(:trace_id) { Datadog::Tracing::Utils::TraceId.next_id }

it { is_expected.to have_attributes(trace_id: trace_id) }
end
Expand Down

0 comments on commit d023dc4

Please sign in to comment.