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

[CIVIS-8333] improvements for manual tracing API #108

Merged
merged 10 commits into from
Jan 18, 2024

Conversation

anmarchenko
Copy link
Contributor

@anmarchenko anmarchenko commented Jan 17, 2024

What does this PR do?
This PR is aimed to simplify and improve manual test tracing API. These changes are the last planned breaking changes before 1.0 release of this library when we'll declare this API stable.

Changes include:

  • Datadog::CI.trace now accept type as optional keyword argument ("span" by default) - this method is used to trace any custom spans inside the test
  • When tracing custom span we raise an error if type is one of ["test", "test_suite_end", "test_module_end", "test_session_end"] - these events are reserved for CI visibility and must be created via respective manual API methods (CI.start_test, CI.start_test_suite, CI.start_test_module, CI.start_test_session)
  • Datadog::CI.active_span does not have type parameter anymore and returns any custom span (not having CI-specific type) that is active now in Datadog::Tracing::Tracer
  • Ext::AppTypes constants are part of public API now
  • Datadog::CI::TestVisibility::Recorder#deactivate_test no longer accepts arguments and deactivates any test that is currently running (as we allow a single test running at any time per thread/fiber)
  • Removes CI.deactivate_* methods as they had a very weird place in the API: being public but declared internal and not to be used by API consumers. Instead, Datadog::CI::Span now has direct access to the Datadog::CI::TestVisibility::Recorder singleton instance via Datadog.components
  • Removes NullSpan class and "Null object" pattern for CI visibility models: while it was an interesting experiment, it made class hierarchy less sound (i.e. NullSpan is a child of Span but not Test, which made me put set_parameters method in Span when it belongs to Test). I had to either provide Null* classes for every CI model or revert to having nil values and nil checks. I chose the latter approach for simplicity and less confusion.

Overall, this PR led to more deleted lines of code than added which I consider a very good result when doing refactoring.

Motivation
First stable version is to be released soon and last minute improvements due for manual API.

@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2024

Codecov Report

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

Comparison is base (8dd092a) 99.10% compared to head (c89c711) 99.10%.
Report is 7 commits behind head on main.

Files Patch % Lines
lib/datadog/ci/utils/git.rb 71.42% 2 Missing ⚠️
lib/datadog/ci/contrib/rspec/example.rb 83.33% 1 Missing ⚠️
lib/datadog/ci/test_visibility/serializers/base.rb 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
- Coverage   99.10%   99.10%   -0.01%     
==========================================
  Files         149      147       -2     
  Lines        6383     6269     -114     
  Branches      277      286       +9     
==========================================
- Hits         6326     6213     -113     
+ Misses         57       56       -1     

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

@anmarchenko anmarchenko marked this pull request as ready for review January 18, 2024 14:08
@anmarchenko anmarchenko requested review from a team as code owners January 18, 2024 14:08
@anmarchenko anmarchenko merged commit a21b953 into main Jan 18, 2024
26 checks passed
@anmarchenko anmarchenko deleted the anmarchenko/trace_remove_type_param branch January 18, 2024 15:18
@github-actions github-actions bot added this to the 0.7.0 milestone Jan 18, 2024
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.

None yet

3 participants