Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Apply DD_VERSION on all spans that use the default or global service name #4075

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/datadog/tracing/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def resolve_tags(tags, service)
tags || @tags.dup
end
# Remove version tag if service is not the default service
if merged_tags.key?(Core::Environment::Ext::TAG_VERSION) && service != @default_service
if merged_tags.key?(Core::Environment::Ext::TAG_VERSION) && service && service != @default_service
merged_tags.delete(Core::Environment::Ext::TAG_VERSION)
end
merged_tags
Expand Down
48 changes: 39 additions & 9 deletions spec/datadog/tracing/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,45 @@
expect(span.get_tag('my')).to eq('tag')
end

context 'contains version and span.service is not equal to the default tracer service' do
let(:tracer_options) { { default_service: 'global-service', tags: { version: '1.1.0' } } }
let(:service) { 'my-service' }
it 'does not set version on the span' do
expect(tracer.default_service).to eq('global-service')
expect(span.service).not_to eq('my-service')

expect(tracer.tags).to include(version: '1.1.0')
expect(span.tags).not_to include(:version)
context 'contains version and the span service name' do
let(:tracer_options) do
{ default_service: 'global-service', tags: { Datadog::Core::Environment::Ext::TAG_VERSION => '1.1.0' } }
end
let(:options) { { service: service } }

context 'is nil' do
let(:service) { nil }

it 'sets version' do
expect(tracer.default_service).to eq('global-service')
expect(span.service).to eq('global-service')

expect(tracer.tags).to include('version' => '1.1.0')
expect(span.tags).to include('version' => '1.1.0')
end
end

context 'is equal to the default tracer service' do
let(:service) { 'global-service' }

it 'sets version' do
expect(tracer.default_service).to eq('global-service')
expect(span.service).to eq('global-service')

expect(tracer.tags).to include('version' => '1.1.0')
expect(span.tags).to include('version' => '1.1.0')
end
end

context 'is not equal to the default tracer service' do
let(:service) { 'local-service' }
it 'does not set version' do
expect(tracer.default_service).to eq('global-service')
expect(span.service).to eq('local-service')

expect(tracer.tags).to include('version' => '1.1.0')
expect(span.tags).not_to include('version' => '1.1.0')
end
end
end

Expand Down
Loading