-
Notifications
You must be signed in to change notification settings - Fork 129
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-612 Add active span concept to Tracer #187
RUMM-612 Add active span concept to Tracer #187
Conversation
When a Span is created without parent it assigns the active span of the current execution context if exists, so spans can now inherit from a span even when they initially don't know about it, or keep a reference. The implemantation uses os.activity framework to create activities when the spans are started, and keep a reference to this id in SpanContext. ActiveSpanUtils keep a map with all the relation activity_id and Spans, where spans are added on creation and removed on finish. When we want to know the active Span we get the current activity and locate the Span associated with it
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.
it's not that i request changes, i just didn't understand why we need os_activity
code
we could keep track of all the spans created with a singleton object instead of relying on os_activity
, am i missing something?
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 like this feature 💪👌, it's so powerful 😱!
Beside CR comments, I have some more notes on it:
Flakiness
I noticed a flakiness in TracerTests
when running all tests locally. Let's get rid of it as well 👌.
os.activity
APIs
I can see some APIs which seem unsafe. Are we sure this won't put our users in trouble with Apple validation? This can be also checked by dogfooding it in our mobile app.
Backward compatibility
As we are using few unsafe APIs in there - I think we should dogfood it well before merging to master
. Because we're close to Tracing GA, this might mean that this feature will be shipped in 1.4.0
. And here I'm not sure, as this change doesn't look backward-compatible: if users start using 1.3.0
, the 1.4.0
will drastically change their traces on app.datadoghq.com, no? WDYT on this point @buranmert @nachoBonafonte ?
All platform tests
- The CI is red, let's fix it and run all-platform-tests after.
Tests/DatadogTests/Datadog/Tracing/Utils/ActiveSpanUtilsTest.swift
Outdated
Show resolved
Hide resolved
Tests/DatadogTests/Datadog/Tracing/Utils/ActiveSpanUtilsTest.swift
Outdated
Show resolved
Hide resolved
About the backward compatibility, yes, it should probably be evaluated and check throroughly before adding to master, probably |
That's true. It will only impact the code that doesn't reference parent span explicitly 👍. |
@test-all-platforms |
2 similar comments
@test-all-platforms |
@test-all-platforms |
@test-all-platforms nachoBonafonte/RUMM-612-Add-active-span-concept-to-Tracer |
@test-all-platforms nachoBonafonte/RUMM-612-Add-active-span-concept-to-Tracer |
we may try to fix that thread sanitizer issue when we have time one day 🎗️ |
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.
Please also squash the commits so their names follow the guideline:
- Make sure each commit and the PR mention the Issue number or JIRA reference
We also need to fix one more thing in Now, they get linked as a single trace: This is because the fixture starts next requests without making sure the previous one did complete. Let's keep them separate (do one by one), so we keep the clean preview of different span configuration in APM Traces Explorer. |
@ncreated the required change is in |
Yes, I can make the change as part of the PR |
Added latest changes |
…re, they were created with a existing activeSpan
Co-authored-by: Maciek Grzybowski <[email protected]>
- make activeSpanPool a standard class and a member of the tracer - Make activeSPan part of the OTTracer standard
…he Tracer + real request captured by intercepting the URLSession's protocol
…cky solutions in swift
…nd DDSpanContext. Convert activityId and activityState in private members Clean currentActivity logic in ObjcOSActivityUtils, static var not needed
… if ThreadSanitizer doesn't fail
…d to see if fixes Threadsanitizer
…chronized to see if fixes Threadsanitizer" This reverts commit 30d57fb.
…thread sanitizer hung" This reverts commit db9de27.
This reverts commit 54044e4.
…iginal completion method Address some more PR comments
…orrect after previous changes
After fixing URLSessionSwizzler finishing spans, this spans are now root spans
8536551
to
ff64969
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.
🚀
What and why?
When a Span is created without parent it assigns the active span of the current execution context if exists, so spans can now inherit from a span even when they initially don't know about it, or keep a reference to it
How?
The implemantation uses os.activity framework to create activities when the spans are started, and keep a reference to this id in SpanContext.
ActiveSpanUtils keep a map with all the relation activity_id and Spans, where spans are added on creation and removed on finish.
When we want to know the active Span we get the current activity and locate the Span associated with it
Also changed some tests that were failing because spans were not being finished properly and next test was inheriting from previous spans creates
Review checklist