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

Allow auto termination of spans #1748

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Allow auto termination of spans #1748

merged 1 commit into from
Dec 10, 2024

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Dec 6, 2024

Goal

Implements auto-termination of spans. This is achieved by checking whether a span has AutoTerminationMode.ON_BACKGROUND just before the session payload is constructed, and terminating it and its descendants if this is true.

Testing

Added integration tests.

@fractalwrench fractalwrench force-pushed the auto-term branch 3 times, most recently from 7d42475 to a1b0918 Compare December 6, 2024 13:50
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.42%. Comparing base (56eb868) to head (e880753).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ndroid/embracesdk/internal/spans/SpanRepository.kt 90.47% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1748      +/-   ##
==========================================
+ Coverage   85.29%   85.42%   +0.12%     
==========================================
  Files         464      464              
  Lines       10791    10818      +27     
  Branches     1595     1601       +6     
==========================================
+ Hits         9204     9241      +37     
+ Misses        870      860      -10     
  Partials      717      717              
Files with missing lines Coverage Δ
...ernal/envelope/session/SessionPayloadSourceImpl.kt 100.00% <100.00%> (ø)
...esdk/internal/injection/PayloadSourceModuleImpl.kt 97.46% <100.00%> (+0.06%) ⬆️
...ndroid/embracesdk/internal/spans/SpanRepository.kt 90.19% <90.47%> (+0.19%) ⬆️

... and 6 files with indirect coverage changes

@fractalwrench fractalwrench changed the base branch from add-auto-term-enum to auto-term-param December 6, 2024 14:10
@fractalwrench fractalwrench force-pushed the auto-term branch 3 times, most recently from da0c39e to 8c566c8 Compare December 6, 2024 15:33
@fractalwrench fractalwrench changed the title [WIP] Allow auto termination of spans Allow auto termination of spans Dec 6, 2024
@fractalwrench fractalwrench marked this pull request as ready for review December 6, 2024 15:36
@fractalwrench fractalwrench requested a review from a team as a code owner December 6, 2024 15:36
@@ -101,4 +102,50 @@ class SpanRepository {
}

private fun notTracked(spanId: String): Boolean = activeSpans[spanId] == null && completedSpans[spanId] == null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will you be adding unit tests that verify this works with different edge-case combinations of descendants which might change the traversal logic? Like if a child is no longer active, but the grand child is active?

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

LGTM. Question about adding more test cases for different combinations of span states. We need to make sure that after backgrounding, all active spans belonging to traces whose root as auto terminate configured will be terminated, irrespective of the state of its ancestors.

Base automatically changed from auto-term-param to main December 9, 2024 10:01
Copy link
Contributor

github-actions bot commented Dec 9, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@fractalwrench
Copy link
Contributor Author

@bidetofevil I added some extra test cases to the integration test & made some slight tweaks to the implementation, so putting this out for review again.

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

LGTM

@fractalwrench fractalwrench merged commit 053b1e1 into main Dec 10, 2024
7 checks passed
@fractalwrench fractalwrench deleted the auto-term branch December 10, 2024 10:09
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.

2 participants