Skip to content

RUM-10040: Perform lazy capture of DatadogContext at the span creation#2662

Merged
0xnm merged 1 commit into
nogorodnikov/rum-8170/feature-context-syncfrom
nogorodnikov/rum-10040/do-lazy-capture-of-rum-context-at-span-start
May 21, 2025
Merged

RUM-10040: Perform lazy capture of DatadogContext at the span creation#2662
0xnm merged 1 commit into
nogorodnikov/rum-8170/feature-context-syncfrom
nogorodnikov/rum-10040/do-lazy-capture-of-rum-context-at-span-start

Conversation

@0xnm

@0xnm 0xnm commented May 20, 2025

Copy link
Copy Markdown
Member

What does this PR do?

Right now when span is started and bundleWithRum=true in OpenTracing or OpenTelemetry tracers configuration, we are doing a call to get RUM context in the synchronous way, thus blocking a caller thread.

With the migration to the context processing thread, we cannot allow long blocking on the caller thread, so in this PR we do a lazy capture of the DatadogContext at the span creation time and add a captor as a span tag.

Later on it is safe to access value captured at the span write stage, because withWriteContext will also be executed on the context processing thread, meaning by that time the call we did before (withContext) to capture initial context will be completed.

This PR aims to glue the blocking/sync API of tracing and async API of the event/context processing.

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 requested review from a team as code owners May 20, 2025 11:28
@codecov-commenter

codecov-commenter commented May 20, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.08%. Comparing base (a3206f3) to head (27b870a).
⚠️ Report is 186 commits behind head on nogorodnikov/rum-8170/feature-context-sync.

Files with missing lines Patch % Lines
.../android/trace/opentelemetry/OtelTracerProvider.kt 85.71% 0 Missing and 1 partial ⚠️
.../kotlin/com/datadog/android/trace/AndroidTracer.kt 85.71% 1 Missing ⚠️
...dog/android/trace/internal/data/OtelTraceWriter.kt 95.65% 0 Missing and 1 partial ⚠️
...datadog/android/trace/internal/data/TraceWriter.kt 95.65% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                              Coverage Diff                               @@
##           nogorodnikov/rum-8170/feature-context-sync    #2662      +/-   ##
==============================================================================
- Coverage                                       70.09%   70.08%   -0.01%     
==============================================================================
  Files                                             819      820       +1     
  Lines                                           30615    30630      +15     
  Branches                                         5111     5118       +7     
==============================================================================
+ Hits                                            21458    21466       +8     
- Misses                                           7742     7746       +4     
- Partials                                         1415     1418       +3     
Files with missing lines Coverage Δ
...in/com/datadog/android/core/internal/SdkFeature.kt 91.89% <100.00%> (+2.33%) ⬆️
...g/android/internal/concurrent/CompletableFuture.kt 100.00% <100.00%> (ø)
...m/datadog/opentelemetry/trace/OtelSpanBuilder.java 24.19% <100.00%> (-0.81%) ⬇️
.../android/trace/opentelemetry/OtelTracerProvider.kt 95.49% <85.71%> (-1.01%) ⬇️
.../kotlin/com/datadog/android/trace/AndroidTracer.kt 96.25% <85.71%> (+0.51%) ⬆️
...dog/android/trace/internal/data/OtelTraceWriter.kt 92.00% <95.65%> (+2.00%) ⬆️
...datadog/android/trace/internal/data/TraceWriter.kt 94.55% <95.65%> (+0.26%) ⬆️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@0xnm
0xnm merged commit 8893ced into nogorodnikov/rum-8170/feature-context-sync May 21, 2025
@0xnm
0xnm deleted the nogorodnikov/rum-10040/do-lazy-capture-of-rum-context-at-span-start branch May 21, 2025 10:03
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.

5 participants