-
-
Notifications
You must be signed in to change notification settings - Fork 225
QOL: Allow finishing spans and transactions with using
#4627
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
Draft
jamescrosswell
wants to merge
7
commits into
version6
Choose a base branch
from
dispose-span
base: version6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+148
−41
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0adcefc
ISpan implements IDisposable
jamescrosswell 0ac4ade
Merge branch 'version6' into dispose-span
jamescrosswell 0b0fdff
Changelog
jamescrosswell 4e5f03d
Update ApiApprovalTests.Run.Net4_8.verified.txt
jamescrosswell 69ce439
Merge branch 'version6' into dispose-span
jamescrosswell 5260090
Apply suggestion from @jamescrosswell
jamescrosswell 349bfa5
Review feedback
jamescrosswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,14 @@ namespace Sentry; | |
/// <summary> | ||
/// Transaction tracer. | ||
/// </summary> | ||
public class TransactionTracer : IBaseTracer, ITransactionTracer | ||
public sealed class TransactionTracer : IBaseTracer, ITransactionTracer | ||
jamescrosswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
private readonly IHub _hub; | ||
private readonly SentryOptions? _options; | ||
private readonly Timer? _idleTimer; | ||
private long _cancelIdleTimeout; | ||
private readonly SentryStopwatch _stopwatch = SentryStopwatch.StartNew(); | ||
private int _hasFinished = 0; | ||
|
||
private readonly Instrumenter _instrumenter = Instrumenter.Sentry; | ||
|
||
|
@@ -361,6 +362,12 @@ public void Clear() | |
/// <inheritdoc /> | ||
public void Finish() | ||
{ | ||
// TODO: Replace with InterlockedBoolean once this has been merged into version6 | ||
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. TODO (as a "resolvable" comment) |
||
if (Interlocked.Exchange(ref _hasFinished, 1) == 1) | ||
jamescrosswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
return; | ||
} | ||
|
||
_options?.LogDebug("Attempting to finish Transaction '{0}'.", SpanId); | ||
if (Interlocked.Exchange(ref _cancelIdleTimeout, 0) == 1) | ||
{ | ||
|
@@ -431,4 +438,19 @@ private void ReleaseSpans() | |
#endif | ||
_activeSpanTracker.Clear(); | ||
} | ||
|
||
/// <summary> | ||
/// <para> | ||
/// Automatically finishes the transaction with a status of <see cref="SpanStatus.Ok" /> at the end of a | ||
/// <c>using</c> block, if it has not already been finished. | ||
/// </para> | ||
/// <para> | ||
/// This is the equivalent of calling <see cref="Finish()" /> when the transaction passes out of scope. | ||
/// </para> | ||
/// </summary> | ||
/// <remarks>This is a convenience method only. Disposing is not required.</remarks> | ||
public void Dispose() | ||
{ | ||
Finish(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question: Is it worth a consideration to make
SpanTracer
internal, too? (in a potential follow-up)So that users cannot run into
CA2000
Or is it a potential user code scenario to try to cast?
But this could have quite a large impact.
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.
Yeah I'm not sure if people are trying to cast these.
I think for the time being we should leave it as is. Eventually the plan is to get rid of transactions and, at that point, there's probably less need to cast from ISpan so we could re-evaluate.