-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Changes from all commits
0adcefc
0ac4ade
0b0fdff
4e5f03d
69ce439
5260090
349bfa5
07394ea
742c079
24e8e8f
8ad0aa0
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 |
|---|---|---|
|
|
@@ -7,12 +7,13 @@ 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 readonly SentryStopwatch _stopwatch = SentryStopwatch.StartNew(); | ||
| private InterlockedBoolean _hasFinished; | ||
|
|
||
| private InterlockedBoolean _cancelIdleTimeout; | ||
|
|
||
|
|
@@ -362,6 +363,11 @@ public void Clear() | |
| /// <inheritdoc /> | ||
| public void Finish() | ||
| { | ||
| if (_hasFinished.Exchange(true)) | ||
| { | ||
| return; | ||
|
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. question: Timer
Wait ... I read this wrong ... this is actually what is happening:
Collaborator
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. The timer is only relevant if idle timeouts are enabled. That was added by Sean here: I think there were plans to maybe use transactions that timed out automatically to instrument MAUI, but this hasn't yet been done. So, in practice, that code path is never executed. I'm not sure I understand though - do you think there's a potential problem here? In what scenario? |
||
| } | ||
|
|
||
jamescrosswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| _options?.LogDebug("Attempting to finish Transaction '{0}'.", SpanId); | ||
| if (_cancelIdleTimeout.Exchange(false) == true) | ||
| { | ||
|
|
@@ -432,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(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.