Skip to content

sentry-tower possibly finishes transaction too early for streaming bodies #1053

@lcian

Description

@lcian

In sentry-tower, SentryHttpFuture starts a transaction on first poll, but it finishes the transaction as soon as the inner service future resolves to Response<ResBody>.

This can result in arguably wrong span durations when using streaming responses (e.g. using axum::body::Body::from_stream in a HTTP handler), as the transaction is ended as soon as the server starts responding.
Instead, the span should probably last for the entire duration of the response, until the body has finished streaming (either due to normal ending of the request of some kind of error along the way).

This is up for discussion, as it should probably be checked what other SDKs/OTEL do when dealing with streaming responses and align with those approaches. So, the current behavior might be correct. But intuitively I think it's wrong.
Also, I don't know if it's possible to implement such a change without relying directly on axum, this might not be possible at the tower level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingRustSDKSpans
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions