Skip to content

Commit 104fbed

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

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,12 @@
8686
//! [our contribution guide]: https://orogene.dev/CONTRIBUTING/
8787
//! [Apache 2.0 License]: https://github.com/orogene/orogene/blob/main/LICENSE
8888
89+
#[cfg(feature = "error-reporting")]
90+
use std::{borrow::Cow, panic::PanicInfo, sync::Arc};
8991
use std::{
90-
borrow::Cow,
9192
collections::VecDeque,
9293
ffi::OsString,
93-
panic::PanicInfo,
9494
path::{Path, PathBuf},
95-
sync::Arc,
9695
};
9796

9897
use async_trait::async_trait;
@@ -598,6 +597,7 @@ impl Orogene {
598597
.into_diagnostic()
599598
}
600599

600+
#[cfg(feature = "error-reporting")]
601601
fn setup_telemetry(
602602
&self,
603603
log_file: Option<PathBuf>,
@@ -700,6 +700,7 @@ impl Orogene {
700700
.map(|c| c.join("_logs").join(log_file_name()));
701701
let _logging_guard = oro.setup_logging(log_file.as_deref())?;
702702
oro.first_time_setup()?;
703+
#[cfg(feature = "error-reporting")]
703704
let _telemetry_guard = oro.setup_telemetry(log_file.clone())?;
704705
let do_term_progress = !oro.quiet && oro.progress;
705706
if do_term_progress {
@@ -723,6 +724,7 @@ impl Orogene {
723724
tracing::debug!("{e:?}");
724725
if let Some(log_file) = log_file.as_deref() {
725726
tracing::warn!("A debug log was written to {}", log_file.display());
727+
#[cfg(feature = "error-reporting")]
726728
sentry::configure_scope(|s| {
727729
s.add_attachment(sentry::protocol::Attachment {
728730
filename: log_file
@@ -735,7 +737,9 @@ impl Orogene {
735737
});
736738
});
737739
}
740+
#[cfg(feature = "error-reporting")]
738741
let dyn_err: &dyn std::error::Error = e.as_ref();
742+
#[cfg(feature = "error-reporting")]
739743
sentry::capture_error(dyn_err);
740744
e
741745
})?;

0 commit comments

Comments
 (0)