-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat: Observe transaction on scope #4153
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
Changes from all commits
dbbf35d
f4cf166
6179c8d
0dd5fe5
26c5319
1277e78
7365c5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,6 +225,20 @@ public ITransactionTracer? Transaction | |
| try | ||
| { | ||
| _transaction.Value = value; | ||
|
|
||
| if (Options.EnableScopeSync) | ||
| { | ||
| if (_transaction.Value != null) | ||
| { | ||
| // If there is a transaction set we propagate the trace to the native layer | ||
| Options.ScopeObserver?.SetTrace(_transaction.Value.TraceId, _transaction.Value.SpanId); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it just the TraceId and SpanId that need to be synced? Should the sample rate and sample rand also be synced (we normally put that on the DSC to ensure consistent sampling decisions)? Or will this just be used to create spans (not transactions) and so no sampling decisions need to be made?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, they should. But both the iOS and Android ScopeObservers are missing their implementation. See #4074 It needs bumping the native SDKs to specific versions and then mess around with the bindings (especially, since the API is in private/internal parts of the Cocoa/Java SDK)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please raise a ticket in the relevant repos so we don't forget about this |
||
| } | ||
| else | ||
| { | ||
| // If the transaction is being removed from the scope, reset and sync the trace as well | ||
| Options.ScopeObserver?.SetTrace(PropagationContext.TraceId, PropagationContext.SpanId); | ||
bitsandfoxes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
| finally | ||
| { | ||
|
|
@@ -802,6 +816,11 @@ internal void ResetTransaction(ITransactionTracer? expectedCurrentTransaction) | |
| if (ReferenceEquals(_transaction.Value, expectedCurrentTransaction)) | ||
| { | ||
| _transaction.Value = null; | ||
| if (Options.EnableScopeSync) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, this could also look like this and have the property take care of locking and synching. But I'm not fully confident in this looking at the way it's set up right originally. cc @jamescrosswell
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I wonder if we need the locking at all. It's an @bruno-garcia sanity check?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it's always AsyncLocal we don't need any locking |
||
| { | ||
| // We have to restore the trace on the native layers to be in sync with the current scope | ||
| Options.ScopeObserver?.SetTrace(PropagationContext.TraceId, PropagationContext.SpanId); | ||
| } | ||
| } | ||
| } | ||
| finally | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.