Skip to content

Commit

Permalink
exploring using RSpec scoped_id metadata as parameters metadata to ma…
Browse files Browse the repository at this point in the history
…ke sure examples have unique fingerprint
  • Loading branch information
anmarchenko committed Jan 12, 2024
1 parent eb7066a commit 76f2a35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/datadog/ci/contrib/rspec/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def run(example_group_instance, reporter)
},
service: configuration[:service_name]
) do |test_span|
test_span.set_parameters({}, {"scoped_id" => metadata[:scoped_id]})

result = super

case execution_result.status
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/ci/span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def set_default_tags
# @param [Hash] metadata optional metadata
# @return [void]
def set_parameters(arguments, metadata = {})
return if arguments.nil? || arguments.empty?
return if arguments.nil?

set_tag(
Ext::Test::TAG_PARAMETERS,
Expand Down
6 changes: 5 additions & 1 deletion spec/datadog/ci/contrib/rspec/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,12 @@ def rspec_session_run(with_failed_test: false, with_shared_test: false)
shared_test_spans = test_spans.filter { |test_span| test_span.name == "SomeTest shared examples adds 1 and 1" }
expect(shared_test_spans).to have(2).items

shared_test_spans.each do |shared_test_span|
shared_test_spans.each_with_index do |shared_test_span, index|
expect(shared_test_span.get_tag(Datadog::CI::Ext::Test::TAG_SUITE)).to eq(spec.file_path)

expect(shared_test_span.get_tag(Datadog::CI::Ext::Test::TAG_PARAMETERS)).to eq(
"{\"arguments\":{},\"metadata\":{\"scoped_id\":\"1:#{2 + index}:1\"}}"
)
end

test_spans.each do |test_span|
Expand Down

0 comments on commit 76f2a35

Please sign in to comment.