RUM-9940: Make getDatadogContext read on the context thread#2645
Conversation
Datadog Summary✅ Code Quality ✅ Code Security ✅ Dependencies Was this helpful? Give us feedback! |
f5803d3 to
ae8aedd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## nogorodnikov/rum-8170/feature-context-sync #2645 +/- ##
==============================================================================
- Coverage 70.09% 70.07% -0.02%
==============================================================================
Files 819 819
Lines 30615 30611 -4
Branches 5111 5111
==============================================================================
- Hits 21458 21449 -9
+ Misses 7742 7740 -2
- Partials 1415 1422 +7
🚀 New features to boost your workflow:
|
| override fun getDatadogContext(): DatadogContext? { | ||
| return contextProvider?.context | ||
| return coreFeature.contextExecutorService | ||
| .submitSafe("getDatadogContext", internalLogger, Callable { contextProvider?.context }) |
There was a problem hiding this comment.
is this going to block if the queue is not ready ?
There was a problem hiding this comment.
Yes, it will. This call is blocking on purpose.
| internal val dataWriter: DataWriter<UserInfo> | ||
| ) : MutableUserInfoProvider { | ||
|
|
||
| @Volatile |
There was a problem hiding this comment.
shouldn't this be atomic instead ? Volatile only guarantees the visibility between 2 threads.
There was a problem hiding this comment.
There is no difference between AtomicReference.get / AtomicReference.set usage and volatile modifier usage (link). There is a difference in case of CAS usage, but it is not needed here.
There was a problem hiding this comment.
Should things like CoreFeature.clientToken link become volatile as well?
There was a problem hiding this comment.
This is the thing to address in the future PRs, but so far it is good without it, because it is used only in the upload cycle which is scheduled only few seconds after SDK is initialized (-> when CoreFeature gets clientToken set).
And it is reset to empty string only when SDK is stopped anyway.
Overall I will align the properties used in the DatadogContext creation later.
What does this PR do?
This PR makes
DatadogCore.getDatadogContextcall readDatadogContexton the context thread in the blocking manner to align with context changes.Review checklist (to be filled by reviewers)