Drop sentry dependencies when enable-sentry feature is disabled (#4372)

This commit is contained in:
teor 2022-05-11 15:00:14 +10:00 committed by GitHub
parent 06f58fba95
commit 17c5e9ad6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 8 deletions

View File

@ -11,9 +11,13 @@ default-run = "zebrad"
[features] [features]
default = [] default = []
# Production features that activate extra dependencies
enable-sentry = ["sentry", "sentry-tracing"]
# Testing features that activate extra dependencies
proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl", "zebra-consensus/proptest-impl", "zebra-network/proptest-impl"] proptest-impl = ["proptest", "proptest-derive", "zebra-chain/proptest-impl", "zebra-state/proptest-impl", "zebra-consensus/proptest-impl", "zebra-network/proptest-impl"]
enable-sentry = []
test_sync_to_mandatory_checkpoint_mainnet = [] test_sync_to_mandatory_checkpoint_mainnet = []
test_sync_to_mandatory_checkpoint_testnet = [] test_sync_to_mandatory_checkpoint_testnet = []
test_sync_past_mandatory_checkpoint_mainnet = [] test_sync_past_mandatory_checkpoint_mainnet = []
@ -57,12 +61,14 @@ dirs = "4.0.0"
inferno = { version = "0.11.3", default-features = false } inferno = { version = "0.11.3", default-features = false }
atty = "0.2.14" atty = "0.2.14"
sentry-tracing = "0.23.0"
sentry = { version = "0.23.0", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls"] }
num-integer = "0.1.45" num-integer = "0.1.45"
rand = { version = "0.8.5", package = "rand" } rand = { version = "0.8.5", package = "rand" }
# prod feature enable-sentry
sentry-tracing = { version = "0.23.0", optional = true }
sentry = { version = "0.23.0", default-features = false, features = ["backtrace", "contexts", "reqwest", "rustls"], optional = true }
# test feature proptest-impl
proptest = { version = "0.10.1", optional = true } proptest = { version = "0.10.1", optional = true }
proptest-derive = { version = "0.3.0", optional = true } proptest-derive = { version = "0.3.0", optional = true }

View File

@ -1,3 +1,5 @@
//! The Abscissa component for Zebra's `tracing` implementation.
use abscissa_core::{Component, FrameworkError, FrameworkErrorKind, Shutdown}; use abscissa_core::{Component, FrameworkError, FrameworkErrorKind, Shutdown};
use tracing_error::ErrorLayer; use tracing_error::ErrorLayer;
use tracing_subscriber::{ use tracing_subscriber::{
@ -48,10 +50,11 @@ impl Tracing {
None None
}; };
let subscriber = builder let subscriber = builder.finish().with(ErrorLayer::default());
.finish()
.with(ErrorLayer::default()) #[cfg(feature = "enable-sentry")]
.with(sentry_tracing::layer()); let subscriber = subscriber.with(sentry_tracing::layer());
match (flamelayer, journaldlayer) { match (flamelayer, journaldlayer) {
(None, None) => subscriber.init(), (None, None) => subscriber.init(),
(Some(layer1), None) => subscriber.with(layer1).init(), (Some(layer1), None) => subscriber.with(layer1).init(),

View File

@ -36,4 +36,6 @@ pub mod commands;
pub mod components; pub mod components;
pub mod config; pub mod config;
pub mod prelude; pub mod prelude;
#[cfg(feature = "enable-sentry")]
pub mod sentry; pub mod sentry;