Skip to content

ref: Remove empty integrations #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2020
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

**Deprecations**:

- The `error-chain` and `failure` integration was officialy deprecated and will be removed soon.
- The `error-chain` and `failure` integration was officially deprecated and will be removed soon.

## 0.20.1

Expand Down
27 changes: 2 additions & 25 deletions sentry-anyhow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
//! # Example
//!
//! ```no_run
//! use sentry_anyhow::{capture_anyhow, AnyhowIntegration};
//! use sentry_anyhow::capture_anyhow;
//!
//! fn function_that_might_fail() -> anyhow::Result<()> {
//! Err(anyhow::anyhow!("some kind of error"))
//! }
//!
//! let _sentry = sentry::init(sentry::ClientOptions::new().add_integration(AnyhowIntegration));
//!
//! if let Err(err) = function_that_might_fail() {
//! capture_anyhow(&err);
//! }
Expand All @@ -22,28 +20,7 @@
#![deny(unsafe_code)]

use sentry_core::types::Uuid;
use sentry_core::{ClientOptions, Hub, Integration};

/// The Sentry anyhow Integration.
#[derive(Debug, Default)]
pub struct AnyhowIntegration;

impl AnyhowIntegration {
/// Creates a new anyhow Integration.
pub fn new() -> Self {
Self::default()
}
}

impl Integration for AnyhowIntegration {
fn name(&self) -> &'static str {
"anyhow"
}

fn setup(&self, cfg: &mut ClientOptions) {
cfg.in_app_exclude.push("anyhow::");
}
}
use sentry_core::Hub;

/// Captures an `anyhow::Error`.
///
Expand Down
10 changes: 5 additions & 5 deletions sentry-backtrace/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ pub fn process_event_stacktrace(stacktrace: &mut Stacktrace, options: &ClientOpt
None => {}
}

for m in &options.in_app_exclude {
for m in &options.in_app_include {
if function_starts_with(func_name, m) {
frame.in_app = Some(false);
frame.in_app = Some(true);
any_in_app = true;
break;
}
}
Expand All @@ -60,10 +61,9 @@ pub fn process_event_stacktrace(stacktrace: &mut Stacktrace, options: &ClientOpt
continue;
}

for m in &options.in_app_include {
for m in &options.in_app_exclude {
if function_starts_with(func_name, m) {
frame.in_app = Some(true);
any_in_app = true;
frame.in_app = Some(false);
break;
}
}
Expand Down
6 changes: 6 additions & 0 deletions sentry-backtrace/src/trim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ lazy_static::lazy_static! {
// these are not modules but things like __rust_maybe_catch_panic
"__rust_",
"___rust_",
// these are well-known library frames
"anyhow::",
"log::",
];

static ref WELL_KNOWN_BORDER_FRAMES: Vec<&'static str> = vec![
"std::panicking::begin_panic",
"core::panicking::panic",
// well-known library frames
"anyhow::",
"<sentry_log::Logger as log::Log>::log",
];

// TODO: remove all of this together with the deprecated `error_chain` support
Expand Down
24 changes: 0 additions & 24 deletions sentry-log/src/integration.rs

This file was deleted.

8 changes: 1 addition & 7 deletions sentry-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
//! log::set_boxed_logger(Box::new(logger)).unwrap();
//! log::set_max_level(log::LevelFilter::Info);
//!
//! let log_integration = sentry_log::LogIntegration::default();
//! let _sentry = sentry::init(
//! sentry::ClientOptions::new().add_integration(sentry_log::LogIntegration::new()),
//! );
//! let _sentry = sentry::init(());
//!
//! log::info!("Generates a breadcrumb");
//! log::error!("Generates an event");
Expand All @@ -39,12 +36,9 @@
#![doc(html_favicon_url = "https://sentry-brand.storage.googleapis.com/favicon.ico")]
#![doc(html_logo_url = "https://sentry-brand.storage.googleapis.com/sentry-glyph-black.png")]
#![warn(missing_docs)]
#![allow(clippy::match_like_matches_macro)]

mod converters;
mod integration;
mod logger;

pub use converters::*;
pub use integration::LogIntegration;
pub use logger::*;
6 changes: 1 addition & 5 deletions sentry-log/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,7 @@ impl<L: log::Log> SentryLogger<L> {

impl<L: log::Log> log::Log for SentryLogger<L> {
fn enabled(&self, metadata: &log::Metadata<'_>) -> bool {
self.dest.enabled(metadata)
|| match (self.filter)(metadata) {
LogFilter::Ignore => false,
_ => true,
}
self.dest.enabled(metadata) || !matches!((self.filter)(metadata), LogFilter::Ignore)
}

fn log(&self, record: &log::Record<'_>) {
Expand Down
6 changes: 1 addition & 5 deletions sentry-slog/src/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ impl<D: Drain> slog::Drain for SentryDrain<D> {
}

fn is_enabled(&self, level: slog::Level) -> bool {
self.drain.is_enabled(level)
|| match (self.filter)(level) {
LevelFilter::Ignore => false,
_ => true,
}
self.drain.is_enabled(level) || !matches!((self.filter)(level), LevelFilter::Ignore)
}
}
18 changes: 0 additions & 18 deletions sentry-slog/src/integration.rs

This file was deleted.

17 changes: 6 additions & 11 deletions sentry-slog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
//!
//! ```
//! use sentry::{init, ClientOptions};
//! use sentry_slog::{SentryDrain, SlogIntegration};
//! use sentry_slog::SentryDrain;
//!
//! let options = ClientOptions::new().add_integration(SlogIntegration::new());
//! let _sentry = sentry::init(options);
//! let _sentry = sentry::init(());
//!
//! let drain = SentryDrain::new(slog::Discard);
//! let root = slog::Logger::root(drain, slog::o!());
//!
//! # let options = ClientOptions::new().add_integration(SlogIntegration::new());
//! # let events = sentry::test::with_captured_events_options(|| {
//! # let events = sentry::test::with_captured_events(|| {
//! slog::info!(root, "recorded as breadcrumb");
//! slog::warn!(root, "recorded as regular event");
//! # }, options.clone());
//! # });
//! # let captured_event = events.into_iter().next().unwrap();
//!
//! assert_eq!(
Expand All @@ -35,9 +33,9 @@
//! Some("recorded as regular event")
//! );
//!
//! # let events = sentry::test::with_captured_events_options(|| {
//! # let events = sentry::test::with_captured_events(|| {
//! slog::crit!(root, "recorded as exception event");
//! # }, options);
//! # });
//! # let captured_event = events.into_iter().next().unwrap();
//!
//! assert_eq!(captured_event.exception.len(), 1);
Expand Down Expand Up @@ -70,12 +68,9 @@
#![doc(html_logo_url = "https://sentry-brand.storage.googleapis.com/sentry-glyph-black.png")]
#![warn(missing_docs)]
#![deny(unsafe_code)]
#![allow(clippy::match_like_matches_macro)]

mod converters;
mod drain;
mod integration;

pub use converters::*;
pub use drain::{default_filter, LevelFilter, RecordMapping, SentryDrain};
pub use integration::SlogIntegration;
11 changes: 4 additions & 7 deletions sentry/examples/log-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ use log_ as log;
fn main() {
init_log();

let _sentry = sentry::init(
sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
}
.add_integration(sentry_log::LogIntegration::new()),
);
let _sentry = sentry::init(sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
});

debug!("System is booting");
info!("System is booting");
Expand Down
11 changes: 4 additions & 7 deletions sentry/examples/thread-demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ fn main() {
// this initializes sentry. It also gives the thread that calls this some
// special behavior in that all other threads spawned will get a hub based on
// the hub from here.
let _sentry = sentry::init(
sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
}
.add_integration(sentry_log::LogIntegration::new()),
);
let _sentry = sentry::init(sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
});

// the log integration sends to Hub::current()
log::info!("Spawning thread");
Expand Down
38 changes: 16 additions & 22 deletions sentry/tests/test_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ fn test_log() {
.map(|()| log::set_max_level(log::LevelFilter::Info))
.unwrap();

let events = sentry::test::with_captured_events_options(
|| {
sentry::configure_scope(|scope| {
scope.set_tag("worker", "worker1");
});

log::info!("Hello World!");
log::error!("Shit's on fire yo");
},
sentry::ClientOptions::new().add_integration(sentry_log::LogIntegration::new()),
);
let events = sentry::test::with_captured_events(|| {
sentry::configure_scope(|scope| {
scope.set_tag("worker", "worker1");
});

log::info!("Hello World!");
log::error!("Shit's on fire yo");
});

assert_eq!(events.len(), 1);
let event = events.into_iter().next().unwrap();
Expand All @@ -37,17 +34,14 @@ fn test_slog() {
let drain = sentry_slog::SentryDrain::new(slog::Discard);
let root = slog::Logger::root(drain, slog::o!());

let events = sentry::test::with_captured_events_options(
|| {
sentry::configure_scope(|scope| {
scope.set_tag("worker", "worker1");
});

slog::info!(root, "Hello World!");
slog::error!(root, "Shit's on fire yo");
},
sentry::ClientOptions::new().add_integration(sentry_slog::SlogIntegration::new()),
);
let events = sentry::test::with_captured_events(|| {
sentry::configure_scope(|scope| {
scope.set_tag("worker", "worker1");
});

slog::info!(root, "Hello World!");
slog::error!(root, "Shit's on fire yo");
});

assert_eq!(events.len(), 1);
let event = events.into_iter().next().unwrap();
Expand Down