sentry-java
sentry-java copied to clipboard
Sentry Invalidating Transactions for unfinished Spans
Integration
sentry-android
Build System
Gradle
AGP Version
8.2.2
Proguard
Enabled
Version
7.3.0
Steps to Reproduce
Start a transaction and hold a reference to it. I've seen both scoped and non-scoped transactions have the effect, but I think scoped transaction are more likely. With that transaction, start a child span, but don't finish it. Finish the transaction.
Expected Result
I would expect the child spans to be stopped when the transaction stops. Their span status should probably be SpanStatus.ABORTED.
Actual Result
If we query our project metrics from the statsV2 endpoint, there are a very high number of invalid_transaction.
In 24 hours, here are the results of the Stats V2 endpoint
Outcome Reason
accepted none : 3356853
client_discard cache_overflow : 184
client_discard sample_rate : 704095
client_discard network_error : 50311
client_discard queue_overflow : 23
invalid invalid_transaction : 1893851
If the following code is used as the tracing callback, a coworker who experienced lost transactions was able to see them.
beforeSendTransaction = SentryOptions.BeforeSendTransactionCallback { transaction, _ ->
val finishedVsUnfinishedSpans = transaction.spans.partition { it.isFinished }
if (finishedVsUnfinishedSpans.second.isNotEmpty()) {
with(transaction) {
spans.clear()
spans.addAll(finishedVsUnfinishedSpans.first)
}
}
transaction
}
┆Issue is synchronized with this Jira Improvement by Unito