Skip to content

Commit

Permalink
[ci-visibility] Add test.framework_version Tag to rspec and `cucu…
Browse files Browse the repository at this point in the history
…mber` (#1713)

Co-authored-by: Marco Costa <marco.costa@datadoghq.com>
  • Loading branch information
juan-fernandez and marcotc committed Oct 11, 2021
1 parent 9427cdc commit db80ca4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dd-ci/ci-app-spec.json
Expand Up @@ -3,6 +3,7 @@
"test.name",
"test.status",
"test.framework",
"test.framework_version",
"test.type",
"ci.provider.name",
"ci.pipeline.id",
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/ci/contrib/cucumber/formatter.rb
Expand Up @@ -39,6 +39,7 @@ def on_test_case_started(event)
service: configuration[:service_name]
},
framework: Ext::FRAMEWORK,
framework_version: Datadog::CI::Contrib::Cucumber::Integration.version.to_s,
test_name: event.test_case.name,
test_suite: event.test_case.location.file,
test_type: Ext::TEST_TYPE
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/ci/contrib/rspec/example.rb
Expand Up @@ -37,6 +37,7 @@ def run(example_group_instance, reporter)
service: configuration[:service_name]
},
framework: Ext::FRAMEWORK,
framework_version: Datadog::CI::Contrib::RSpec::Integration.version.to_s,
test_name: test_name,
test_suite: file_path,
test_type: Ext::TEST_TYPE
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/ci/ext/test.rb
Expand Up @@ -8,6 +8,7 @@ module Test

TAG_ARGUMENTS = 'test.arguments'.freeze
TAG_FRAMEWORK = 'test.framework'.freeze
TAG_FRAMEWORK_VERSION = 'test.framework_version'.freeze
TAG_NAME = 'test.name'.freeze
TAG_SKIP_REASON = 'test.skip_reason'.freeze # DEV: Not populated yet
TAG_STATUS = 'test.status'.freeze
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/ci/test.rb
Expand Up @@ -42,6 +42,7 @@ def self.set_tags!(span, tags = {})

# Set contextual tags
span.set_tag(Ext::Test::TAG_FRAMEWORK, tags[:framework]) if tags[:framework]
span.set_tag(Ext::Test::TAG_FRAMEWORK_VERSION, tags[:framework_version]) if tags[:framework_version]
span.set_tag(Ext::Test::TAG_NAME, tags[:test_name]) if tags[:test_name]
span.set_tag(Ext::Test::TAG_SUITE, tags[:test_suite]) if tags[:test_suite]
span.set_tag(Ext::Test::TAG_TYPE, tags[:test_type]) if tags[:test_type]
Expand Down
3 changes: 3 additions & 0 deletions spec/datadog/ci/contrib/rspec/instrumentation_spec.rb
Expand Up @@ -45,6 +45,9 @@ def with_new_rspec_environment
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_SPAN_KIND)).to eq(Datadog::CI::Ext::AppTypes::TEST)
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_TYPE)).to eq(Datadog::CI::Contrib::RSpec::Ext::TEST_TYPE)
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_FRAMEWORK)).to eq(Datadog::CI::Contrib::RSpec::Ext::FRAMEWORK)
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_FRAMEWORK_VERSION)).to eq(
Datadog::CI::Contrib::RSpec::Integration.version.to_s
)
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS)).to eq(Datadog::CI::Ext::Test::Status::PASS)
end

Expand Down
12 changes: 12 additions & 0 deletions spec/datadog/ci/test_spec.rb
Expand Up @@ -123,6 +123,18 @@
end
end

context 'when :framework_version is given' do
let(:tags) { { framework_version: framework_version } }
let(:framework_version) { 'framework_version' }

before { set_tags! }

it do
expect(span.get_tag(Datadog::CI::Ext::Test::TAG_FRAMEWORK_VERSION))
.to eq(framework_version)
end
end

context 'when :test_name is given' do
let(:tags) { { test_name: test_name } }
let(:test_name) { 'test name' }
Expand Down

0 comments on commit db80ca4

Please sign in to comment.