From c6b0a33823f689e2f6fdcb4eff9ce5eebdbf6d27 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 10:33:23 +0000 Subject: [PATCH] ref(log): Migrate to individual sentry-tracing layers (DO NOT MERGE) Co-Authored-By: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> --- Cargo.lock | 33 +++++++++++-------------------- Cargo.toml | 18 +++++++++++++++++ objectstore-log/src/subscriber.rs | 26 +++++++++++------------- objectstore-server/src/web/app.rs | 5 ++--- 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8657fd6..8d6d26da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4177,8 +4177,7 @@ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "sentry" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa951f4e644464ebfd2347a7ab03b0828c512d2448a76262cad2607b343dff4" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "cfg_aliases", "httpdate", @@ -4200,8 +4199,7 @@ dependencies = [ [[package]] name = "sentry-actix" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909d0a93b15d1ddcde3894aa23d003cbefc39ef53fe6d7c8294357ced2969cfb" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "actix-http", "actix-web", @@ -4213,8 +4211,7 @@ dependencies = [ [[package]] name = "sentry-backtrace" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f27cf048aa63ccd5bc94c29989133eabb82e9c6bf7441b58e9d4a95837a105" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "backtrace", "regex", @@ -4224,8 +4221,7 @@ dependencies = [ [[package]] name = "sentry-contexts" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5ed680585dbdacdf9859c2b4dc53358ff02bd256766882e22e343836db36b22" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "hostname", "libc", @@ -4238,8 +4234,7 @@ dependencies = [ [[package]] name = "sentry-core" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ed398494bb8fc412a11a182c1883a10ae147587b8f6314abd222d1d626f31b" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "rand 0.10.2", "sentry-types", @@ -4251,8 +4246,7 @@ dependencies = [ [[package]] name = "sentry-debug-images" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55854bb40681e84ffd2a69578ad4ef9bfaf5bf2bf1380a745578b591fa24af22" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "findshlibs", "sentry-core", @@ -4261,8 +4255,7 @@ dependencies = [ [[package]] name = "sentry-log" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3dc14009e1c24b07a8ff9ff8e1bcd0913b3e448b1565e679414776f2e58651" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "bitflags", "log", @@ -4304,8 +4297,7 @@ dependencies = [ [[package]] name = "sentry-panic" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7153e68642b761ed3aa62c022795c11b2facc728b2db7484084492373c944f9" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "sentry-backtrace", "sentry-core", @@ -4314,8 +4306,7 @@ dependencies = [ [[package]] name = "sentry-tower" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624ee2c60caf72fa2cd6be00334b3a3ce0c6df3b1f01941ea62e3d244492d334" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "axum", "http 1.4.2", @@ -4329,8 +4320,7 @@ dependencies = [ [[package]] name = "sentry-tracing" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e7db1aefdf623f4e48e21ec9e4af535024187aeafb2a4cc7e29d035def5a13" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "bitflags", "sentry-backtrace", @@ -4342,8 +4332,7 @@ dependencies = [ [[package]] name = "sentry-types" version = "0.49.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c18bf7b159bdfc7c8f97816f476b4947a1937fb6bea9d38d3479e58631614ac" +source = "git+https://github.com/getsentry/sentry-rust?branch=szokeasaurusrex%2Fdeprecate-tracing-helpers#2d59a9977030d6116c416af3dbd422a036cd1281" dependencies = [ "debugid", "hex", diff --git a/Cargo.toml b/Cargo.toml index afab6d58..24e5088e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,3 +122,21 @@ uuid = { version = "1.23.3", features = ["v4"] } yansi = "1.0.1" zstd = "0.13.3" zstd-safe = "7.2.4" + +# DO NOT MERGE: test the unreleased sentry-tracing layer API from +# https://github.com/getsentry/sentry-rust/pull/1348. Patching (rather than +# changing the `sentry` requirement) keeps every crate in the graph, including +# `sentry_arroyo` and `objectstore-client` via `sentry-core`, on a single copy +# of the SDK so they share one Hub. +[patch.crates-io] +sentry = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-actix = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-backtrace = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-contexts = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-core = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-debug-images = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-log = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-panic = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-tower = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-tracing = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } +sentry-types = { git = "https://github.com/getsentry/sentry-rust", branch = "szokeasaurusrex/deprecate-tracing-helpers" } diff --git a/objectstore-log/src/subscriber.rs b/objectstore-log/src/subscriber.rs index d14525be..2a73d539 100644 --- a/objectstore-log/src/subscriber.rs +++ b/objectstore-log/src/subscriber.rs @@ -1,7 +1,6 @@ use tracing_subscriber::prelude::*; use tracing_subscriber::{EnvFilter, Registry}; -use crate::Level; use crate::config::{LogFormat, LoggingConfig}; // Generated by build.rs: `const CRATE_NAMES: &[&str]` listing all objectstore workspace crates. @@ -13,26 +12,23 @@ include!(concat!(env!("OUT_DIR"), "/constants.gen.rs")); /// for internal objectstore crates. Log format (`pretty`, `simplified`, or `json`) is determined /// by `config.format`, defaulting to pretty when a terminal is attached. /// -/// When built with the `sentry` feature, also attaches a Sentry tracing layer if the Sentry client -/// has been initialized. `ERROR` and `WARN` events become Sentry events; `INFO`/`DEBUG` become -/// Sentry logs; `TRACE` events are ignored. `ERROR`..`DEBUG` spans become Sentry spans; `TRACE` -/// spans are ignored. +/// When built with the `sentry` feature, also attaches Sentry tracing layers if the Sentry client +/// has been initialized. `ERROR` and `WARN` events become Sentry events and Sentry logs; +/// `INFO`/`DEBUG` become Sentry logs; `TRACE` events are ignored. `ERROR`..`DEBUG` spans become +/// Sentry spans; `TRACE` spans are ignored. pub fn init(config: &LoggingConfig) { #[cfg(feature = "sentry")] let sentry_layer = sentry::Hub::current() .client() .filter(|c| c.is_enabled()) .map(|_| { - use sentry::integrations::tracing as sentry_tracing; - sentry_tracing::layer() - .event_filter(|metadata| match *metadata.level() { - Level::ERROR | Level::WARN => { - sentry_tracing::EventFilter::Event | sentry_tracing::EventFilter::Log - } - Level::INFO | Level::DEBUG => sentry_tracing::EventFilter::Log, - Level::TRACE => sentry_tracing::EventFilter::Ignore, - }) - .span_filter(|metadata| !matches!(*metadata.level(), Level::TRACE)) + use sentry::integrations::tracing::{ErrorLayer, LogLayer, SpanLayer}; + use tracing_subscriber::filter::LevelFilter; + + SpanLayer::new() + .with_filter(LevelFilter::DEBUG) + .and_then(ErrorLayer::new().with_filter(LevelFilter::WARN)) + .and_then(LogLayer::new().with_filter(LevelFilter::DEBUG)) }); let format = tracing_subscriber::fmt::layer() diff --git a/objectstore-server/src/web/app.rs b/objectstore-server/src/web/app.rs index f3dd96c7..8ca34b65 100644 --- a/objectstore-server/src/web/app.rs +++ b/objectstore-server/src/web/app.rs @@ -98,7 +98,6 @@ impl App { mod tests { use axum::body::{Body, to_bytes}; use axum::http::StatusCode; - use objectstore_log::tracing; use objectstore_service::backend::local_fs::FileSystemConfig; use sentry::protocol::{Context, EnvelopeItem, TraceContext, Transaction}; use tower::ServiceExt; @@ -123,8 +122,8 @@ mod tests { .unwrap(); let _subscriber = tracing_subscriber::registry() .with( - sentry::integrations::tracing::layer() - .span_filter(|metadata| *metadata.level() != tracing::Level::TRACE), + sentry::integrations::tracing::SpanLayer::new() + .with_filter(tracing_subscriber::filter::LevelFilter::DEBUG), ) .set_default(); let trace_id = "11111111111111111111111111111111";