Skip to content

Throwable is missing in transaction #4365

@zhukic

Description

@zhukic

Integration

sentry-android

Build System

Gradle

AGP Version

8.9.1

Proguard

Enabled

Version

8.8.0

Steps to Reproduce

Hi,

I've implemented a custom OkHttp interceptor that measures the time taken to execute an HTTP request(described here). It goes well but in case if a request fails due to some exception we don't see the exception in Sentry, only the transaction's status.

Pseudocode:

class HttpLoggingInterceptor() : Interceptor {

    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val transaction = Sentry.startTransaction(name = request.path, operation = "http.client")
        // A separate span needed for having calls on the "Network Requests" page
        val span = transaction.startChild(operation = "http.client", description = "${request.method} $path")

        return try {
            val response = chain.proceed(request)
            val status = SpanStatus.fromHttpStatusCode(response.code)
            transaction.setData(KEY_HTTP_RESPONSE_CODE, code)
            span.setData(KEY_HTTP_RESPONSE_CODE, code)

            response
        } catch (e: Exception) {
            transaction.throwable = exception
            transaction.status = SpanStatus.INTERNAL_ERROR
            span.throwable = exception
            span.status = SpanStatus.INTERNAL_ERROR

            throw e
        } finally {
            span.finish()
            transaction.finish()
        }
    }
}

When an exception occurs, I see on the debug panel that the transaction.throwable field is not null during transaction.finish() call, but when I put a breakpoint on my custom EventProcessor the throwable is missing and it's missing on the transaction's page as well.

Expected Result

The throwable is presented on the transaction's page.

Actual Result

The throwable is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions