Skip to content

Commit

Permalink
fix: use latest sentry
Browse files Browse the repository at this point in the history
A prior version of Sentry was less strict on guard handling, the
latest fully tears down the transport. The guard now lives for the
duration of the server to avoid the teardown.
  • Loading branch information
bbangert committed Sep 6, 2018
1 parent b55295f commit 79b0fed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ reqwest = { version = "0.8.6", features = ["unstable"] }
rusoto_core = "0.32.0"
rusoto_credential = "0.11.0"
rusoto_dynamodb = "0.32.0"
# sentry = { version = "0.9.0", features = ["with_error_chain"] }
sentry = { version = "0.9.0", features = ["with_error_chain"] }
# XXX: pinned until server side's upgraded
serde = "1.0.70"
serde_derive = "1.0.70"
Expand Down Expand Up @@ -71,9 +71,3 @@ woothee = "0.7.3"
[dependencies.config]
git = "https://github.com/mehcode/config-rs"
rev = "e8fa9fee96185ddd18ebcef8a925c75459111edb"

[dependencies.sentry]
features = ["with_error_chain"]
git = "https://github.com/getsentry/sentry-rust/"
# Sentry 0.9.0 is broken, this is the last commit that works before 0.9.0
rev = "0e99cdd6bc5377ce151084e432a66af91e4b5d17"
33 changes: 15 additions & 18 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,28 @@ struct ShutdownHandle(oneshot::Sender<()>, thread::JoinHandle<()>);
pub struct AutopushServer {
opts: Arc<ServerOptions>,
shutdown_handles: Cell<Option<Vec<ShutdownHandle>>>,
_guard: Option<sentry::internals::ClientInitGuard>,
}

impl AutopushServer {
pub fn new(opts: ServerOptions) -> Self {
let guard = if let Ok(dsn) = env::var("SENTRY_DSN") {
let guard = sentry::init((
dsn,
sentry::ClientOptions {
release: sentry_crate_release!(),
..Default::default()
}
));
register_panic_handler();
Some(guard)
} else {
None
};
Self {
opts: Arc::new(opts),
shutdown_handles: Cell::new(None),
_guard: guard,
}
}

Expand Down Expand Up @@ -215,7 +230,6 @@ impl Server {
/// be used to interact with it (e.g. shut it down).
fn start(opts: &Arc<ServerOptions>) -> Result<Vec<ShutdownHandle>> {
let mut shutdown_handles = vec![];
let _guard = Server::start_sentry();

let (inittx, initrx) = oneshot::channel();
let (donetx, donerx) = oneshot::channel();
Expand Down Expand Up @@ -262,23 +276,6 @@ impl Server {
}
}

/// Setup Sentry logging if a SENTRY_DSN exists
fn start_sentry() -> Option<sentry::internals::ClientInitGuard> {
if let Ok(dsn) = env::var("SENTRY_DSN") {
let guard = sentry::init((
dsn,
sentry::ClientOptions {
release: sentry_crate_release!(),
..Default::default()
}
));
register_panic_handler();
Some(guard)
} else {
None
}
}

fn new(opts: &Arc<ServerOptions>) -> Result<(Rc<Server>, Core)> {
let core = Core::new()?;
let broadcaster = if let Some(ref megaphone_url) = opts.megaphone_api_url {
Expand Down

0 comments on commit 79b0fed

Please sign in to comment.