Skip to content
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ description = """
Sentry (getsentry.com) client for rust ;)
"""
build = "build.rs"
edition = "2018"
autoexamples = true

[package.metadata.docs.rs]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ We currently only verify this crate against a recent version of Sentry hosted on
[sentry.io](https://sentry.io/) but it should work with on-prem Sentry versions
8.20 and later.

Additionally, the lowest Rust version we target is _1.31.0_.

## Resources

- [crates.io](https://crates.io/crates/sentry)
Expand Down
3 changes: 0 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(feature = "with_rust_info")]
extern crate rustc_version;

use std::env;
use std::fs::File;
use std::io::Write;
Expand Down
2 changes: 0 additions & 2 deletions examples/before-send.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate sentry;

use std::sync::Arc;

fn main() {
Expand Down
4 changes: 1 addition & 3 deletions examples/error-chain-demo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate sentry;

use sentry::integrations::error_chain::capture_error_chain;

Expand All @@ -25,7 +23,7 @@ fn main() {
.parse()
.unwrap(),
),
release: sentry_crate_release!(),
release: sentry::release_name!(),
..Default::default()
});

Expand Down
2 changes: 0 additions & 2 deletions examples/event-processors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate sentry;

fn main() {
let client =
sentry::Client::from_config("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156");
Expand Down
9 changes: 2 additions & 7 deletions examples/failure-demo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
extern crate failure;
#[macro_use]
extern crate failure_derive;
#[macro_use]
extern crate sentry;

use failure::Fail;
use sentry::integrations::failure::capture_error;

#[derive(Fail, Debug)]
Expand All @@ -25,7 +20,7 @@ fn main() {
let _sentry = sentry::init((
"https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156",
sentry::ClientOptions {
release: sentry_crate_release!(),
release: sentry::release_name!(),
..Default::default()
},
));
Expand Down
2 changes: 0 additions & 2 deletions examples/init-with-client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate sentry;

fn main() {
let client =
sentry::Client::from_config("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156");
Expand Down
7 changes: 1 addition & 6 deletions examples/log-demo.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
extern crate log;
extern crate pretty_env_logger;
extern crate sentry;

use log::{debug, error, info, warn};
use sentry::sentry_crate_release;

fn main() {
let _sentry = sentry::init((
"https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156",
sentry::ClientOptions {
release: sentry_crate_release!(),
release: sentry::release_name!(),
..Default::default()
},
));
Expand Down
2 changes: 0 additions & 2 deletions examples/message-demo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate sentry;

fn main() {
let _sentry = sentry::init("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156");
sentry::configure_scope(|scope| {
Expand Down
5 changes: 1 addition & 4 deletions examples/panic-demo.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#[macro_use]
extern crate sentry;

fn main() {
let _sentry = sentry::init((
"https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156",
sentry::ClientOptions {
release: sentry_crate_release!(),
release: sentry::release_name!(),
..Default::default()
},
));
Expand Down
2 changes: 0 additions & 2 deletions examples/send-with-extra.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate sentry;

fn main() {
let _sentry = sentry::init("https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156");

Expand Down
14 changes: 4 additions & 10 deletions examples/thread-demo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#[macro_use]
extern crate log;
extern crate pretty_env_logger;
#[macro_use]
extern crate sentry;

use std::sync::Arc;
use std::thread;

Expand All @@ -14,7 +8,7 @@ fn main() {
let _sentry = sentry::init((
"https://a94ae32be2584e0bbd7a4cbb95971fee@sentry.io/1041156",
sentry::ClientOptions {
release: sentry_crate_release!(),
release: sentry::release_name!(),
..Default::default()
},
));
Expand All @@ -25,12 +19,12 @@ fn main() {
sentry::integrations::panic::register_panic_handler();

// the log integration sends to Hub::current()
info!("Spawning thread");
log::info!("Spawning thread");

thread::spawn(|| {
// The thread spawned here gets a new hub cloned from the hub of the
// main thread.
info!("Spawned thread, configuring scope.");
log::info!("Spawned thread, configuring scope.");

// now we want to create a new hub based on the thread's normal hub for
// working with it explicitly.
Expand All @@ -47,7 +41,7 @@ fn main() {
sentry::Hub::run(hub, || {
// the log integration picks up the Hub::current which is now bound
// to the outer hub.
error!("Failing!");
log::error!("Failing!");
});
})
.join()
Expand Down
1 change: 1 addition & 0 deletions integrations/sentry-actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ documentation = "https://docs.rs/sentry-actix"
description = """
Sentry client extension for actix-web
"""
edition = "2018"

[dependencies]
actix-web = { version = "0.7", default-features = false }
Expand Down
4 changes: 0 additions & 4 deletions integrations/sentry-actix/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
extern crate actix_web;
extern crate sentry;
extern crate sentry_actix;

use std::env;
use std::io;

Expand Down
6 changes: 1 addition & 5 deletions integrations/sentry-actix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@
//! });
//! # }
//! ```
extern crate actix_web;
extern crate failure;
extern crate fragile;
extern crate sentry;

use std::borrow::Cow;
use std::cell::RefCell;
Expand Down Expand Up @@ -326,7 +322,7 @@ impl ActixWebHubExt for Hub {

fn capture_actix_error(&self, err: &Error) -> Uuid {
let mut exceptions = vec![];
let mut ptr: Option<&Fail> = Some(err.as_fail());
let mut ptr: Option<&dyn Fail> = Some(err.as_fail());
let mut idx = 0;
while let Some(fail) = ptr {
// Check whether the failure::Fail held by err is a failure::Error wrapped in Compat
Expand Down
6 changes: 4 additions & 2 deletions src/backtrace_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use regex::{Captures, Regex};

use crate::protocol::{Frame, Stacktrace};

lazy_static! {
lazy_static::lazy_static! {
static ref HASH_FUNC_RE: Regex = Regex::new(r#"(?x)
^(.*)::h[a-f0-9]{16}$
"#).unwrap();
Expand All @@ -27,6 +27,7 @@ pub static ref WELL_KNOWN_SYS_MODULES: Vec<&'static str> = {
}
rv
};

pub static ref WELL_KNOWN_BORDER_FRAMES: Vec<&'static str> = {
#[allow(unused_mut)]
let mut rv = vec![
Expand All @@ -44,6 +45,7 @@ pub static ref WELL_KNOWN_BORDER_FRAMES: Vec<&'static str> = {
}
rv
};

pub static ref SECONDARY_BORDER_FRAMES: Vec<(&'static str, &'static str)> = {
#![allow(unused_mut)]
let mut rv = Vec::new();
Expand Down Expand Up @@ -74,7 +76,7 @@ pub fn strip_symbol(s: &str) -> &str {

pub fn demangle_symbol(s: &str) -> String {
COMMON_RUST_SYMBOL_ESCAPES_RE
.replace_all(s, |caps: &Captures| {
.replace_all(s, |caps: &Captures<'_>| {
match &caps[1] {
"SP" => "@",
"BP" => "*",
Expand Down
14 changes: 7 additions & 7 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ use crate::utils;
/// The Sentry client object.
pub struct Client {
options: ClientOptions,
transport: RwLock<Option<Arc<Box<Transport>>>>,
transport: RwLock<Option<Arc<Box<dyn Transport>>>>,
}

impl fmt::Debug for Client {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Client")
.field("dsn", &self.dsn())
.field("options", &self.options)
Expand All @@ -43,7 +43,7 @@ impl Clone for Client {
}

/// Type alias for before event/breadcrumb handlers.
pub type BeforeCallback<T> = Arc<Box<Fn(T) -> Option<T> + Send + Sync>>;
pub type BeforeCallback<T> = Arc<Box<dyn Fn(T) -> Option<T> + Send + Sync>>;

/// Configuration settings for the client.
pub struct ClientOptions {
Expand All @@ -54,7 +54,7 @@ pub struct ClientOptions {
/// This is typically either a boxed function taking the client options by
/// reference and returning a `Transport`, a boxed `Arc<Transport>` or
/// alternatively the `DefaultTransportFactory`.
pub transport: Box<TransportFactory>,
pub transport: Box<dyn TransportFactory>,
/// module prefixes that are always considered in_app
pub in_app_include: Vec<&'static str>,
/// module prefixes that are never in_app
Expand Down Expand Up @@ -107,7 +107,7 @@ pub struct ClientOptions {
impl RefUnwindSafe for ClientOptions {}

impl fmt::Debug for ClientOptions {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[derive(Debug)]
struct TransportFactory;
#[derive(Debug)]
Expand Down Expand Up @@ -207,7 +207,7 @@ impl Default for ClientOptions {
}
}

lazy_static! {
lazy_static::lazy_static! {
static ref CRATE_RE: Regex = Regex::new(r"^(?:_<)?([a-zA-Z0-9_]+?)(?:\.\.|::)").unwrap();
}

Expand Down Expand Up @@ -385,7 +385,7 @@ impl Client {
mut event: Event<'static>,
scope: Option<&Scope>,
) -> Option<Event<'static>> {
lazy_static! {
lazy_static::lazy_static! {
static ref DEBUG_META: DebugMeta = DebugMeta {
images: utils::debug_images(),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");

include!(concat!(env!("OUT_DIR"), "/constants.gen.rs"));

lazy_static! {
lazy_static::lazy_static! {
pub static ref USER_AGENT: String = format!("sentry.rust/{}", VERSION);
pub static ref SDK_INFO: ClientSdkInfo = ClientSdkInfo {
name: "sentry-rust".into(),
Expand Down
2 changes: 1 addition & 1 deletion src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::scope::{Scope, ScopeGuard};
use crate::{client::Client, scope::Stack, utils};

#[cfg(feature = "with_client_implementation")]
lazy_static! {
lazy_static::lazy_static! {
static ref PROCESS_HUB: (Arc<Hub>, thread::ThreadId) = (
Arc::new(Hub::new(None, Arc::new(Default::default()))),
thread::current().id()
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use crate::hub::Hub;
use crate::internals::Uuid;
use crate::protocol::{Event, Exception, Frame, Level, Stacktrace};

lazy_static! {
lazy_static::lazy_static! {
static ref MODULE_SPLIT_RE: Regex = Regex::new(r"^(.*)::(.*?)$").unwrap();
static ref FRAME_RE: Regex = Regex::new(
r#"(?xm)
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn event_from_error(err: &failure::Error) -> Event<'static> {
pub fn event_from_fail<F: Fail + ?Sized>(fail: &F) -> Event<'static> {
let mut exceptions = vec![exception_from_single_fail(fail, fail.backtrace())];

let mut ptr: Option<&Fail> = None;
let mut ptr: Option<&dyn Fail> = None;
while let Some(cause) = ptr.map(Fail::cause).unwrap_or_else(|| fail.cause()) {
exceptions.push(exception_from_single_fail(cause, cause.backtrace()));
ptr = Some(cause);
Expand Down
Loading