Skip to content

Commit

Permalink
Changed: Identity::tracer_version to ::gem_datadog_version
Browse files Browse the repository at this point in the history
  • Loading branch information
delner committed Mar 18, 2024
1 parent ced0b3b commit 9df537a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/datadog/core/environment/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def lang_version
end

# Returns datadog gem version, rubygems-style
def tracer_version
def gem_datadog_version
Core::Environment::Ext::GEM_DATADOG_VERSION
end

# Returns tracer version, comforming to https://semver.org/spec/v2.0.0.html
def tracer_version_semver2
major, minor, patch, rest = tracer_version.split('.', 4)
def gem_datadog_version_semver2
major, minor, patch, rest = gem_datadog_version.split('.', 4)

semver = "#{major}.#{minor}.#{patch}"

Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/core/metrics/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Options
"#{Ext::TAG_LANG_VERSION}:#{Environment::Identity.lang_version}",
# TODO: Technically not accurate, if tracing version diverges from datadog gem version
# If we extract tracing to its own gem, this needs to be updated.
"#{Ext::TAG_TRACER_VERSION}:#{Environment::Identity.tracer_version}"
"#{Ext::TAG_TRACER_VERSION}:#{Environment::Identity.gem_datadog_version}"
].freeze
}.freeze

Expand Down
16 changes: 8 additions & 8 deletions spec/datadog/core/environment/identity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,42 @@
it { is_expected.to eq(Datadog::Core::Environment::Ext::LANG_VERSION) }
end

describe '::tracer_version' do
subject(:tracer_version) { described_class.tracer_version }
describe '::gem_datadog_version' do
subject(:gem_datadog_version) { described_class.gem_datadog_version }

it { is_expected.to eq(Datadog::Core::Environment::Ext::GEM_DATADOG_VERSION) }
end

describe '::tracer_version_semver2' do
subject(:tracer_version) { described_class.tracer_version_semver2 }
describe '::gem_datadog_version_semver2' do
subject(:gem_datadog_version) { described_class.gem_datadog_version_semver2 }

context 'when not prerelease' do
before do
expect(described_class).to receive(:tracer_version).and_return('10.20.30'.freeze)
expect(described_class).to receive(:gem_datadog_version).and_return('10.20.30'.freeze)
end

it { is_expected.to eq('10.20.30') }
end

context 'when prerelease' do
before do
expect(described_class).to receive(:tracer_version).and_return('10.20.30.beta40'.freeze)
expect(described_class).to receive(:gem_datadog_version).and_return('10.20.30.beta40'.freeze)
end

it { is_expected.to eq('10.20.30-beta40') }
end

context 'when development' do
before do
expect(described_class).to receive(:tracer_version).and_return('10.20.30.b3fe268.gha12345.ga1b2c3d4'.freeze)
expect(described_class).to receive(:gem_datadog_version).and_return('10.20.30.b3fe268.gha12345.ga1b2c3d4'.freeze)
end

it { is_expected.to eq('10.20.30+b3fe268.gha12345.ga1b2c3d4') }
end

context 'when prerelease and development' do
before do
expect(described_class).to receive(:tracer_version).and_return('10.20.30.beta40.b3fe268.gha12345.ga1b2c3d4'.freeze)
expect(described_class).to receive(:gem_datadog_version).and_return('10.20.30.beta40.b3fe268.gha12345.ga1b2c3d4'.freeze)
end

it { is_expected.to eq('10.20.30-beta40+b3fe268.gha12345.ga1b2c3d4') }
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/core/metrics/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"#{Datadog::Core::Metrics::Ext::TAG_LANG}:#{Datadog::Core::Environment::Identity.lang}",
"#{Datadog::Core::Metrics::Ext::TAG_LANG_INTERPRETER}:#{Datadog::Core::Environment::Identity.lang_interpreter}",
"#{Datadog::Core::Metrics::Ext::TAG_LANG_VERSION}:#{Datadog::Core::Environment::Identity.lang_version}",
"#{Datadog::Core::Metrics::Ext::TAG_TRACER_VERSION}:#{Datadog::Core::Environment::Identity.tracer_version}"
"#{Datadog::Core::Metrics::Ext::TAG_TRACER_VERSION}:#{Datadog::Core::Environment::Identity.gem_datadog_version}"
)
end

Expand Down

0 comments on commit 9df537a

Please sign in to comment.