-
Notifications
You must be signed in to change notification settings - Fork 134
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-2334 Tracing with RUM Through Core Context #989
Conversation
Datadog ReportBranch report: ❌ Failed Tests (1)
|
af33959
to
aeb3029
Compare
1f25087
to
75ca11b
Compare
7ad368a
to
b5d1217
Compare
f46ee48
to
9a65ff1
Compare
Datadog ReportBranch report: ❄️ New Flaky Tests (1)
|
9a65ff1
to
512ec08
Compare
512ec08
to
a1f6147
Compare
a1f6147
to
13636b4
Compare
Datadog ReportBranch report: ✅ |
fe152c2
to
19d2354
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In overall it looks good 👍. I left few feedbacks on remaining leftovers and missing tests coverage for context provider.
Sources/Datadog/DatadogCore/Context/DatadogContextProvider.swift
Outdated
Show resolved
Hide resolved
/// Fair and recursive lock. | ||
private let lock = NSRecursiveLock() | ||
|
||
/// Unsafe attributes. | ||
private var _attribues: [String: Encodable]? | ||
|
||
private func synchronize<T>(_ block: () -> T) -> T { | ||
lock.lock() | ||
defer { lock.unlock() } | ||
return block() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know how NSLock
perf compares to DispatchQueue
? Do we have plans on wider use of locks vs queues for other products in similar use case (decorating one Feature events with other Feature context)?
Here we will be running this critical section for each tracer.startSpan()
(on user thread), so overhead is important. If we follow this pattern, similar thing will happen in other Features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here a benchmark: https://www.vadimbulavin.com/benchmarking-locking-apis/
For read operation: DispatchQueue
is 7-8 times slower than locks.
For write operation: DispatchQueue
is 3-4 times slower than locks
DispatchQueue
performs better when using concurrent queue tho. But prior to this change, the Tracer
was doing a sync
on the (serial) queue of the RUMMonitor
from the user thread (here).
Do we have plans on wider use of locks vs queues for other products in similar use case (decorating one Feature events with other Feature context)?
No, it's on a case by case. Here I'm using a lock to avoid syncing the Tracer\queue
from the user-thread. But it really depends on the Feature pipeline.
9d174fb
to
e7cbfcb
Compare
Datadog ReportBranch report: ❌ Failed Tests (1)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
What and why?
Tracing gets RUM context from the message bus.
How?
We can now add
DatadogContextObserver
to theDatadogContextProvider
to get notified when the context changes. TheDatadogCore
is an observer and send a context message on the bus on any context change.Note: The context still have passive values that are read when the context is requested. To get the most up-to-date values we notify the observers on each read operation as well. This was already the case in V1 providers, but this needs to be addressed so any value change generate a push on the message-bus.
Review checklist
Custom CI job configuration (optional)