Skip to content
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

Do not overwrite UI transaction status if set by the user #2852

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Breaking changes:

### Fixes

- Do not overwrite UI transaction status if set by the user ([#2852](https://github.com/getsentry/sentry-java/pull/2852))

Breaking changes:
- Move enableNdk from SentryOptions to SentryAndroidOptions ([#2793](https://github.com/getsentry/sentry-java/pull/2793))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,13 @@ private void startTracing(final @NotNull UiElement target, final @NotNull String

void stopTracing(final @NotNull SpanStatus status) {
if (activeTransaction != null) {
activeTransaction.finish(status);
final SpanStatus currentStatus = activeTransaction.getStatus();
// status might be set by other integrations, let's not overwrite it
if (currentStatus == null) {
activeTransaction.finish(status);
} else {
activeTransaction.finish();
}
}
hub.configureScope(
scope -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import io.sentry.Scope
import io.sentry.ScopeCallback
import io.sentry.SentryTracer
import io.sentry.SpanStatus
import io.sentry.SpanStatus.OUT_OF_RANGE
import io.sentry.TransactionContext
import io.sentry.TransactionOptions
import io.sentry.android.core.SentryAndroidOptions
Expand Down Expand Up @@ -323,6 +324,17 @@ class SentryGestureListenerTracingTest {
verify(fixture.transaction).scheduleFinish()
}

@Test
fun `preserves existing transaction status`() {
val sut = fixture.getSut<View>()

sut.onSingleTapUp(fixture.event)

fixture.transaction.status = OUT_OF_RANGE
sut.stopTracing(SpanStatus.CANCELLED)
assertEquals(OUT_OF_RANGE, fixture.transaction.status)
}

internal open class ScrollableListView : AbsListView(mock()) {
override fun getAdapter(): ListAdapter = mock()
override fun setSelection(position: Int) = Unit
Expand Down
Loading