Skip to content
Open
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Improvements

- With the `debug` option enabled, the SDK now logs a message when it drops a span because the span finished after its transaction was already sent. The `sentry-tracing` docs now explain how this can happen when a library keeps a clone of a `tracing` span ([#1367](https://github.com/getsentry/sentry-rust/pull/1367)).

### Fixes

- [`Transport::flush`](https://docs.rs/sentry-core/0.49.6/sentry_core/trait.Transport.html#method.flush) on an `Arc`-wrapped transport now flushes the inner transport, instead of returning `true` immediately ([#1390](https://github.com/getsentry/sentry-rust/pull/1390)).
Expand Down
9 changes: 9 additions & 0 deletions sentry-core/src/performance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,15 @@ impl Span {
} else if let Some(client) = inner.client.as_ref() {
client.record_lost_data(&*span, ClientReportReason::BufferOverflow);
}
} else if matches!(inner.tracing_state.finish_action(), FinishAction::Send { .. }) {
// The transaction was already sent, so there is nothing left to add this span to.
sentry_debug!(
"[Span] dropping span {} (op: {:?}, description: {:?}) because it finished \
after its transaction was already sent",
span.span_id,
span.op,
span.description,
);
}
}}
}
Expand Down
7 changes: 7 additions & 0 deletions sentry-tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ async fn handle_request(headers: std::collections::HashMap<String, String>) {
}
```

### Spans finishing after their transaction

A Sentry span finishes when its `tracing` span closes, which only happens once every handle to
the `tracing` span is dropped. If a library holds on to a clone, as `sqlx`'s SQLite driver does,
the span can close after its transaction was sent, and is then dropped. To avoid this, manually
start a Sentry span around the affected code.

## Logs

`LogLayer` sends events accepted by its filter as structured logs. Event fields become log
Expand Down
7 changes: 7 additions & 0 deletions sentry-tracing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
//! }
//! ```
//!
//! ## Spans finishing after their transaction
//!
//! A Sentry span finishes when its `tracing` span closes, which only happens once every handle to
//! the `tracing` span is dropped. If a library holds on to a clone, as `sqlx`'s SQLite driver does,
//! the span can close after its transaction was sent, and is then dropped. To avoid this, manually
//! start a Sentry span around the affected code.
//!
//! # Logs
//!
//! `LogLayer` sends events accepted by its filter as structured logs. Event fields become log
Expand Down
Loading