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.
In
sentry-tower,SentryHttpFuturestarts a transaction on first poll, but it finishes the transaction as soon as the inner service future resolves toResponse<ResBody>.This can result in arguably wrong span durations when using streaming responses (e.g. using
axum::body::Body::from_streamin 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 thetowerlevel.