Skip to content

Commit 055e07a

Browse files
committed
feat: conditional sentry reporting via features
Signed-off-by: Sam Gammon <[email protected]>
1 parent 2dc8d9e commit 055e07a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ is-terminal = { workspace = true }
5050
kdl = { workspace = true }
5151
miette = { workspace = true, features = ["fancy"] }
5252
rand = { workspace = true, default_features = false }
53-
sentry = { workspace = true }
53+
sentry = { workspace = true, optional = true }
5454
serde = { workspace = true, features = ["derive"] }
5555
serde_json = { workspace = true }
5656
supports-unicode = { workspace = true }
@@ -73,6 +73,10 @@ repository = "https://github.com/orogene/orogene"
7373
homepage = "https://orogene.dev"
7474
rust-version = "1.67.1"
7575

76+
[features]
77+
default = ["error-reporting"]
78+
error-reporting = ["sentry"]
79+
7680
[workspace.dependencies]
7781
anyhow = "1.0.75"
7882
async-compression = "0.3.5"

src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,14 @@
8787
//! [Apache 2.0 License]: https://github.com/orogene/orogene/blob/main/LICENSE
8888
8989
use std::{
90-
borrow::Cow,
9190
collections::VecDeque,
9291
ffi::OsString,
93-
panic::PanicInfo,
9492
path::{Path, PathBuf},
93+
};
94+
#[cfg(feature = "error-reporting")]
95+
use std::{
96+
borrow::Cow,
97+
panic::PanicInfo,
9598
sync::Arc,
9699
};
97100

@@ -598,6 +601,7 @@ impl Orogene {
598601
.into_diagnostic()
599602
}
600603

604+
#[cfg(feature = "error-reporting")]
601605
fn setup_telemetry(
602606
&self,
603607
log_file: Option<PathBuf>,
@@ -700,6 +704,7 @@ impl Orogene {
700704
.map(|c| c.join("_logs").join(log_file_name()));
701705
let _logging_guard = oro.setup_logging(log_file.as_deref())?;
702706
oro.first_time_setup()?;
707+
#[cfg(feature = "error-reporting")]
703708
let _telemetry_guard = oro.setup_telemetry(log_file.clone())?;
704709
let do_term_progress = !oro.quiet && oro.progress;
705710
if do_term_progress {
@@ -723,6 +728,7 @@ impl Orogene {
723728
tracing::debug!("{e:?}");
724729
if let Some(log_file) = log_file.as_deref() {
725730
tracing::warn!("A debug log was written to {}", log_file.display());
731+
#[cfg(feature = "error-reporting")]
726732
sentry::configure_scope(|s| {
727733
s.add_attachment(sentry::protocol::Attachment {
728734
filename: log_file
@@ -735,7 +741,9 @@ impl Orogene {
735741
});
736742
});
737743
}
744+
#[cfg(feature = "error-reporting")]
738745
let dyn_err: &dyn std::error::Error = e.as_ref();
746+
#[cfg(feature = "error-reporting")]
739747
sentry::capture_error(dyn_err);
740748
e
741749
})?;

0 commit comments

Comments
 (0)