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

Datadog::CI.trace_test always starts a new trace #74

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

anmarchenko
Copy link
Member

@anmarchenko anmarchenko commented Nov 28, 2023

What does this PR do?
Makes sure that when tracing a test we always create a new trace by using continue_from span option

Motivation
In order not to break trace view UI we need to be sure that each test receives its own trace

Additional Notes
Unrelated change:

  • Datadog::CI::Recorder spec is completely rewritten in saner style without endless doubles and expectactions

How to test the change?
Unit tests are provided

@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (8d8cead) 99.30% compared to head (a14f853) 99.32%.

Files Patch % Lines
lib/datadog/ci/test_visibility/transport.rb 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
+ Coverage   99.30%   99.32%   +0.02%     
==========================================
  Files         125      125              
  Lines        4328     4328              
  Branches      153      153              
==========================================
+ Hits         4298     4299       +1     
+ Misses         30       29       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anmarchenko anmarchenko changed the title WIP a single trace per test Datadog::CI.trace_test always starts a new trace Nov 28, 2023
@anmarchenko anmarchenko marked this pull request as ready for review November 28, 2023 16:29
@@ -119,6 +122,11 @@ def trace
end
end

# returns trace associated with given span
def trace_for_span(span)
traces.find { |trace| trace.id == span.trace_id }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double-check: traces contains only currently active traces, right? Asking because of the linear search.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is a spec helper so it is used only in tests to examine the tracer's internal state for our assertions
we never access tracer's state in production like that

@anmarchenko anmarchenko force-pushed the anmarchenko/single_trace_per_test branch from 3ecfd8d to a14f853 Compare November 29, 2023 07:58
@anmarchenko anmarchenko merged commit a5dd26f into main Nov 29, 2023
11 checks passed
@anmarchenko anmarchenko deleted the anmarchenko/single_trace_per_test branch November 29, 2023 08:09
@github-actions github-actions bot added this to the 0.5.0 milestone Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants