-
-
Notifications
You must be signed in to change notification settings - Fork 475
fix: drop app-start transaction when deadline timer fires doze-delayed #5755
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ public final class SentryTracer implements ITransaction { | |
|
|
||
| private volatile @Nullable TimerTask idleTimeoutTask; | ||
| private volatile @Nullable TimerTask deadlineTimeoutTask; | ||
| private volatile long deadlineTimeoutScheduledAtNanos; | ||
|
|
||
| private volatile @Nullable Timer timer = null; | ||
| private final @NotNull AutoClosableReentrantLock timerLock = new AutoClosableReentrantLock(); | ||
|
|
@@ -146,6 +147,48 @@ private void onIdleTimeoutReached() { | |
| } | ||
|
|
||
| private void onDeadlineTimeoutReached() { | ||
| if (isFinished()) { | ||
| isDeadlineTimerRunning.set(false); | ||
| return; | ||
| } | ||
|
|
||
| final @Nullable Long deadlineTimeout = transactionOptions.getDeadlineTimeout(); | ||
| if (deadlineTimeout != null) { | ||
| final long elapsedNanos = | ||
| scopes.getOptions().getDateProvider().now().nanoTimestamp() | ||
| - deadlineTimeoutScheduledAtNanos; | ||
| if (deadlineTimeout > 0 && DateUtils.nanosToMillis(elapsedNanos) > deadlineTimeout * 2.0) { | ||
| scopes | ||
| .getOptions() | ||
| .getLogger() | ||
| .log( | ||
| SentryLevel.DEBUG, | ||
| "Dropping transaction %s because the deadline timer fired too late", | ||
| name); | ||
| root.finish(); | ||
| scopes.configureScope( | ||
| scope -> { | ||
| scope.withTransaction( | ||
| transaction -> { | ||
| if (transaction == this) { | ||
| scope.clearTransaction(); | ||
| } | ||
| }); | ||
| }); | ||
| if (timer != null) { | ||
| try (final @NotNull ISentryLifecycleToken ignored = timerLock.acquire()) { | ||
| if (timer != null) { | ||
| cancelIdleTimer(); | ||
| cancelDeadlineTimer(); | ||
| timer.cancel(); | ||
| timer = null; | ||
| } | ||
| } | ||
| } | ||
| return; | ||
|
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. Drop path skips finish cleanupHigh Severity The late-deadline drop path finishes the root and clears the scope, but it never runs the cleanup that normal Reviewed by Cursor Bugbot for commit 3bc4794. Configure here. |
||
| } | ||
| } | ||
|
|
||
| final @Nullable SpanStatus status = getStatus(); | ||
| forceFinish( | ||
| (status != null) ? status : SpanStatus.DEADLINE_EXCEEDED, | ||
|
|
@@ -310,6 +353,8 @@ private void scheduleDeadlineTimeout() { | |
| if (timer != null) { | ||
| cancelDeadlineTimer(); | ||
| isDeadlineTimerRunning.set(true); | ||
| deadlineTimeoutScheduledAtNanos = | ||
| scopes.getOptions().getDateProvider().now().nanoTimestamp(); | ||
| deadlineTimeoutTask = | ||
| new TimerTask() { | ||
| @Override | ||
|
|
@@ -536,7 +581,8 @@ private ISpan createChild( | |
| .getLogger() | ||
| .log( | ||
| SentryLevel.WARNING, | ||
| "Span operation: %s, description: %s dropped due to limit reached. Returning NoOpSpan.", | ||
| "Span operation: %s, description: %s dropped due to limit reached. Returning" | ||
| + " NoOpSpan.", | ||
| operation, | ||
| description); | ||
| return NoOpSpan.getInstance(); | ||
|
|
@@ -633,7 +679,8 @@ private void setDefaultSpanData(final @NotNull ISpan span) { | |
| .getLogger() | ||
| .log( | ||
| SentryLevel.WARNING, | ||
| "Span operation: %s, description: %s dropped due to limit reached. Returning NoOpSpan.", | ||
| "Span operation: %s, description: %s dropped due to limit reached. Returning" | ||
| + " NoOpSpan.", | ||
| operation, | ||
| description); | ||
| return NoOpSpan.getInstance(); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.