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

[SDTEST-756] add +ci-X.Y.Z to the tracer_version reported to internal telemetry if datadog-ci is present and CI mode is enabled #3881

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ target :datadog do
library 'passenger'
library 'webmock'
library 'graphql'
library 'datadog-ci'

# TODO: gem 'libddwaf'
library 'libddwaf'
Expand Down
14 changes: 13 additions & 1 deletion lib/datadog/core/telemetry/request.rb
anmarchenko marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ def build_payload(event, seq_id)

def application
config = Datadog.configuration

tracer_version = Core::Environment::Identity.gem_datadog_version_semver2

# We need some to distinguish datadog-ci gem versions
# when examining telemetry metrics emitted from the datadog-ci gem.
#
# This code checks that Datadog::CI is loaded and ci mode is enabled and adds
# "-ci-X.Y.Z" suffix to the tracer version.
if defined?(::Datadog::CI::VERSION) && config.respond_to?(:ci) && config.ci.enabled
tracer_version = "#{tracer_version}-ci-#{::Datadog::CI::VERSION::STRING}"
end

{
env: config.env,
language_name: Core::Environment::Ext::LANG,
Expand All @@ -39,7 +51,7 @@ def application
runtime_version: Core::Environment::Ext::ENGINE_VERSION,
service_name: config.service,
service_version: config.version,
tracer_version: Core::Environment::Identity.gem_datadog_version_semver2
tracer_version: tracer_version
anmarchenko marked this conversation as resolved.
Show resolved Hide resolved
}
end

Expand Down
29 changes: 29 additions & 0 deletions spec/datadog/core/telemetry/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,34 @@
tracer_time: tracer_time,
)
end

context "when Datadog::CI is loaded and ci mode is enabled" do
before do
stub_const('Datadog::CI::VERSION::STRING', '1.2.3')
expect(Datadog).to receive(:configuration).and_return(
double(
'configuration',
ci: double('ci', enabled: true),
env: env,
service: service_name,
version: service_version
)
)
end

it do
is_expected.to eq(
api_version: api_version,
application: application.merge(tracer_version: "#{tracer_version}-ci-1.2.3"),
debug: debug,
host: host,
payload: payload,
request_type: request_type,
runtime_id: runtime_id,
seq_id: seq_id,
tracer_time: tracer_time,
)
end
end
end
end
7 changes: 7 additions & 0 deletions vendor/rbs/datadog-ci/0/datadog_ci.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Datadog
module CI
module VERSION
STRING: String
end
end
end
Loading