-
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
RUM-7251 Static trace context caching #2114
RUM-7251 Static trace context caching #2114
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 3553 Passed, 0 Skipped, 2m 24.4s Total Time 🔻 Code Coverage Decreases vs Default Branch (2) |
@@ -34,7 +34,7 @@ public struct URLSessionInterceptor { | |||
/// This is to bridge the gap between what is encoded into HTTP headers and what is later needed for processing | |||
/// the interception (unlike request headers, the `TraceContext` holds the original information on trace sampling). | |||
@ReadWriteLock | |||
private var contextsByTraceID: [TraceID: [TraceContext]] = [:] |
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.
@ncreated, That's the most straightforward option. Another option would be to make this dict a property of the NetworkInstrumentationFeature
but it's out of its responsibility...
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.
I think this fix is good enough given that the entire URLSessionInterceptor
is only used by the deprecated Alamofire instrumentation code. There is no other code that depends on this type, so we can keep it simple 👍.
Another option would be to make this dict a property of the
NetworkInstrumentationFeature
but it's out of its responsibility...
Or another option would be to fix the shared(in:)
method, so it really implements singleton behavior. It should return a single instance of interceptor for given core
. That would be the only change required in this fix, but it will require introducing a new concept of attaching arbitrary objects to core
. Not worth it because URLSessionInterceptor
is already deprecated.
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.
Is it deprecated? URLSessionInterceptor
is still the entry-point for manual URLSession instrumentation, it is used by the deprecated Alamofire extension but its definition is public and not marked as deprecated.
/merge |
Devflow running:
|
e4836d5
to
bfaa3aa
Compare
/merge |
Devflow running:
|
/merge |
Devflow running:
|
What and why?
The
URLSessionInterceptor
keeps a cache of trace context but theshared()
methods returns a new instance each time, leading to trace discontinuity.How?
Make the trace-context cache static.
Review checklist
make api-surface
)