Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 11 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
26 changes: 11 additions & 15 deletions objectstore-log/src/subscriber.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions objectstore-server/src/web/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
Loading