Skip to content

Commit 45ae04d

Browse files
build(deps): Bump sentry from 0.49.3 to 0.49.5 (#741)
Bumps `sentry` from 0.49.3 to 0.49.5 and moves off the deprecated combined `sentry-tracing` layer. **Relevant SDK changes** - Tower integration: `409 Conflict` responses now get the `already_exists` transaction status instead of `invalid_argument` ([sentry-rust#1353](getsentry/sentry-rust#1353)). objectstore returns 409 for resumable offset mismatches, conflicting updates, and when profiling isn't enabled. - `sentry-tracing` is now split into `SpanLayer`, `LogLayer`, `ErrorLayer`, and `BreadcrumbLayer`. `sentry_tracing::layer()` and `EventFilter` are deprecated ([sentry-rust#1342](getsentry/sentry-rust#1342)). **Changes in this PR** - `objectstore-log` now uses the split layers with the same filtering as before: `DEBUG`+ spans, `DEBUG`+ events as logs, `WARN`+ events as error events, nothing at `TRACE`, and no breadcrumbs. - Span attributes are now enabled on logs and error events, so they carry the fields of their parent spans. They were not enabled before. - The test in `web/app.rs` now uses `SpanLayer`. --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Lorenzo Cian <17258265+lcian@users.noreply.github.com>
1 parent 1464ea5 commit 45ae04d

7 files changed

Lines changed: 49 additions & 44 deletions

File tree

‎Cargo.lock‎

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ reqwest = { version = "0.13.4", default-features = false }
8484
ring = "0.17.14"
8585
rustls = { version = "0.23.40", default-features = false }
8686
secrecy = "0.10.3"
87-
sentry = "0.49.3"
87+
sentry = "0.49.5"
8888
sentry-options = "1.2.4"
8989
sentry_arroyo = "2.47.0"
9090
# - `ssl` is required for SASL/SCRAM

‎objectstore-log/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ sentry = ["init", "dep:sentry"]
1818
[dependencies]
1919
anyhow = { workspace = true }
2020
console = { workspace = true, optional = true }
21-
sentry = { workspace = true, features = ["tracing"], optional = true }
21+
sentry = { workspace = true, features = ["tracing", "logs"], optional = true }
2222
serde = { workspace = true }
2323
tracing = { workspace = true }
2424
tracing-subscriber = { workspace = true, features = ["env-filter", "json"], optional = true }

‎objectstore-log/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! `objectstore_log::info!()`. Never import the macros; always qualify at the call site.
77
//! 2. [`LoggingConfig`] and [`LogFormat`] for configuring log level and output format, and
88
//! (behind the `init` feature) an [`init`] function to wire up a `tracing-subscriber` stack.
9-
//! When built with the `sentry` feature, `init` also attaches a Sentry tracing layer if the
9+
//! When built with the `sentry` feature, `init` also attaches Sentry tracing layers if the
1010
//! Sentry client has already been initialized.
1111
//! 3. Custom level macros (`error!`, `warn!`, etc.) that extend their `tracing` equivalents with
1212
//! an optional `!<error>` first argument for ergonomic error field attachment, plus [`event_dyn!`]

‎objectstore-log/src/subscriber.rs‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use tracing_subscriber::prelude::*;
22
use tracing_subscriber::{EnvFilter, Registry};
33

4-
use crate::Level;
54
use crate::config::{LogFormat, LoggingConfig};
65

76
// Generated by build.rs: `const CRATE_NAMES: &[&str]` listing all objectstore workspace crates.
@@ -13,26 +12,33 @@ include!(concat!(env!("OUT_DIR"), "/constants.gen.rs"));
1312
/// for internal objectstore crates. Log format (`pretty`, `simplified`, or `json`) is determined
1413
/// by `config.format`, defaulting to pretty when a terminal is attached.
1514
///
16-
/// When built with the `sentry` feature, also attaches a Sentry tracing layer if the Sentry client
17-
/// has been initialized. `ERROR` and `WARN` events become Sentry events; `INFO`/`DEBUG` become
18-
/// Sentry logs; `TRACE` events are ignored. `ERROR`..`DEBUG` spans become Sentry spans; `TRACE`
19-
/// spans are ignored.
15+
/// When built with the `sentry` feature, also attaches Sentry tracing layers if the Sentry client
16+
/// has been initialized. `ERROR`..`DEBUG` spans become Sentry spans and `ERROR`..`DEBUG` events
17+
/// become Sentry logs. `ERROR` and `WARN` events also become Sentry error events. Logs and error
18+
/// events include the attributes of their parent spans. `TRACE` spans and events are ignored.
2019
pub fn init(config: &LoggingConfig) {
2120
#[cfg(feature = "sentry")]
2221
let sentry_layer = sentry::Hub::current()
2322
.client()
2423
.filter(|c| c.is_enabled())
2524
.map(|_| {
26-
use sentry::integrations::tracing as sentry_tracing;
27-
sentry_tracing::layer()
28-
.event_filter(|metadata| match *metadata.level() {
29-
Level::ERROR | Level::WARN => {
30-
sentry_tracing::EventFilter::Event | sentry_tracing::EventFilter::Log
31-
}
32-
Level::INFO | Level::DEBUG => sentry_tracing::EventFilter::Log,
33-
Level::TRACE => sentry_tracing::EventFilter::Ignore,
34-
})
35-
.span_filter(|metadata| !matches!(*metadata.level(), Level::TRACE))
25+
use sentry::integrations::tracing::{ErrorLayer, LogLayer, SpanLayer};
26+
use tracing_subscriber::filter::{FilterExt, LevelFilter, filter_fn};
27+
28+
SpanLayer::new()
29+
.with_filter(LevelFilter::DEBUG)
30+
.and_then(
31+
ErrorLayer::new()
32+
.enable_span_attributes()
33+
// Span attributes come only from spans that pass both the span layer's
34+
// and the event layer's filter, so the error layer accepts all spans.
35+
.with_filter(LevelFilter::WARN.or(filter_fn(|m| m.is_span()))),
36+
)
37+
.and_then(
38+
LogLayer::new()
39+
.enable_span_attributes()
40+
.with_filter(LevelFilter::DEBUG),
41+
)
3642
});
3743

3844
let format = tracing_subscriber::fmt::layer()

‎objectstore-server/src/observability.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! Call [`init_sentry`] during server startup before creating the Tokio runtime so it can
44
//! instrument async tasks from the start. Tracing subscriber initialization (including the
5-
//! Sentry tracing layer) is handled by [`objectstore_log::init`].
5+
//! Sentry tracing layers) is handled by [`objectstore_log::init`].
66
77
use secrecy::ExposeSecret;
88

‎objectstore-server/src/web/app.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ impl App {
9898
mod tests {
9999
use axum::body::{Body, to_bytes};
100100
use axum::http::StatusCode;
101-
use objectstore_log::tracing;
102101
use objectstore_service::backend::local_fs::FileSystemConfig;
103102
use sentry::protocol::{Context, EnvelopeItem, TraceContext, Transaction};
104103
use tower::ServiceExt;
@@ -123,8 +122,8 @@ mod tests {
123122
.unwrap();
124123
let _subscriber = tracing_subscriber::registry()
125124
.with(
126-
sentry::integrations::tracing::layer()
127-
.span_filter(|metadata| *metadata.level() != tracing::Level::TRACE),
125+
sentry::integrations::tracing::SpanLayer::new()
126+
.with_filter(tracing_subscriber::filter::LevelFilter::DEBUG),
128127
)
129128
.set_default();
130129
let trace_id = "11111111111111111111111111111111";

0 commit comments

Comments
 (0)