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

RUMM-2834: Tracing feature stores context in the common context storage #1216

Conversation

0xnm
Copy link
Member

@0xnm 0xnm commented Jan 4, 2023

What does this PR do?

This change makes tracing feature to store its context (active span) in the common context storage.

The tricky part is that active span (span backed by the current active scope) is thread-local, so each thread may have its own active span. To support such thread-local storage I'm using addScopeListener API to associate the active context with the particular thread and then later to read it from DatadogContext for the particular thread as well (reminder: DatadogContext is created on the caller thread).

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@0xnm 0xnm marked this pull request as ready for review January 5, 2023 12:51
@0xnm 0xnm requested a review from a team as a code owner January 5, 2023 12:51
@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2023

Codecov Report

Merging #1216 (3eaf25d) into feature/sdkv2 (62fa834) will increase coverage by 0.08%.
The diff coverage is 92.31%.

@@                Coverage Diff                @@
##           feature/sdkv2    #1216      +/-   ##
=================================================
+ Coverage          82.67%   82.75%   +0.08%     
=================================================
  Files                353      353              
  Lines              12576    12589      +13     
  Branches            2086     2087       +1     
=================================================
+ Hits               10397    10418      +21     
+ Misses              1541     1528      -13     
- Partials             638      643       +5     
Impacted Files Coverage Δ
.../kotlin/com/datadog/android/v2/api/FeatureScope.kt 50.00% <ø> (ø)
...otlin/com/datadog/android/tracing/AndroidTracer.kt 92.94% <85.71%> (-1.43%) ⬇️
...android/log/internal/domain/DatadogLogGenerator.kt 97.04% <100.00%> (+0.09%) ⬆️
...n/com/datadog/android/v2/core/SdkInternalLogger.kt 88.89% <0.00%> (-5.56%) ⬇️
...src/main/kotlin/com/datadog/android/DatadogSite.kt 83.33% <0.00%> (-3.33%) ⬇️
...in/com/datadog/android/log/internal/LogsFeature.kt 85.38% <0.00%> (-3.08%) ⬇️
...droid/rum/tracking/ActivityViewTrackingStrategy.kt 86.54% <0.00%> (-1.92%) ⬇️
...core/internal/system/DefaultAndroidInfoProvider.kt 83.02% <0.00%> (-1.89%) ⬇️
.../android/rum/internal/monitor/DatadogRumMonitor.kt 90.81% <0.00%> (-0.54%) ⬇️
.../kotlin/com/datadog/android/v2/core/DatadogCore.kt 85.89% <0.00%> (-0.40%) ⬇️
... and 8 more

Copy link
Member

@mariusc83 mariusc83 left a comment

Choose a reason for hiding this comment

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

Nice work !!

@@ -17,7 +17,9 @@ interface FeatureScope {
* @param forceNewBatch if `true` forces the [EventBatchWriter] to write in a new file and
* not reuse the already existing pending data persistence file. By default it is `false`.
* @param callback an operation called with an up-to-date [DatadogContext]
* and an [EventBatchWriter]. Callback will be executed on a worker thread from I/O pool
* and an [EventBatchWriter]. Callback will be executed on a worker thread from I/O pool.
Copy link
Member

Choose a reason for hiding this comment

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

yes...this is what we needed

@0xnm 0xnm merged commit 04b24dc into feature/sdkv2 Jan 6, 2023
@0xnm 0xnm deleted the nogorodnikov/rumm-2834/tracing-feature-stores-context-in-the-common-context-storage branch January 6, 2023 10:10
@xgouchet xgouchet added this to the 1.17.0 milestone Dec 13, 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