Skip to content

Commit

Permalink
Merge pull request DataDog#3651 from DataDog/fix-otel-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed May 16, 2024
2 parents 7ca3042 + 82c91a9 commit cfe3b44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/datadog/opentelemetry/sdk/span_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def span_arguments(span, attributes)
end
attributes.flatten!(1)

kwargs[:tags] = attributes
kwargs[:tags] = attributes.to_h

[name, kwargs]
end
Expand Down
17 changes: 16 additions & 1 deletion spec/datadog/opentelemetry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@

describe '#in_span' do
context 'without an active span' do
subject!(:in_span) { otel_tracer.in_span('test', **span_options) {} }
subject(:in_span) { otel_tracer.in_span('test', **span_options) {} }

it 'records a finished span' do
in_span

expect(span).to be_root_span
expect(span.name).to eq('internal')
expect(span.resource).to eq('test')
Expand All @@ -57,6 +59,14 @@
context 'with attributes' do
let(:span_options) { { attributes: attributes } }

before do
Datadog.configure do |c|
c.tags = { 'global' => 'global_tag' }
end

in_span
end

[
[1, 1],
[false, 'false'],
Expand All @@ -69,6 +79,10 @@
it "sets tag #{expected}" do
expect(span.get_tag('tag')).to eq(expected)
end

it 'keeps the global trace tags' do
expect(span.get_tag('global')).to eq('global_tag')
end
end
end

Expand Down Expand Up @@ -208,6 +222,7 @@
let(:span_options) { { start_timestamp: start_timestamp } }
let(:start_timestamp) { Time.utc(2023) }
it do
in_span
expect(span.start_time).to eq(start_timestamp)
end
end
Expand Down

0 comments on commit cfe3b44

Please sign in to comment.