Skip to content

Commit

Permalink
add sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRollen committed Apr 16, 2021
1 parent 22505b5 commit b130c86
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 79 deletions.
117 changes: 42 additions & 75 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "alpaca-data-relay"
version = "1.0.0"
version = "1.0.1"
authors = ["Sebastian Rollen <[email protected]>"]
edition = "2018"

Expand All @@ -14,7 +14,8 @@ dotenv = "0.15"
futures = "0.3"
kafka-settings = { git = "ssh://[email protected]/Overmuse/kafka-settings", tag = "v0.2.1" }
rdkafka = { version = "0.26", features = ["ssl-vendored"] }
sentry = "0.19.0"
sentry = "0.21.0"
sentry-anyhow = "0.21.0"
serde = "1.0"
serde_json = "1.0"
tokio = {version = "1.0", features = ["macros", "rt-multi-thread"]}
Expand Down
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
use alpaca_data_relay::{run, Settings};
use anyhow::Result;
use dotenv::dotenv;
use sentry_anyhow::capture_anyhow;
use tracing::{info, subscriber::set_global_default};
use tracing_log::LogTracer;
use tracing_subscriber::{filter::EnvFilter, FmtSubscriber};

#[tokio::main]
async fn main() -> Result<()> {
let _guard = sentry::init(sentry::ClientOptions::new());
let _ = dotenv();
let subscriber = FmtSubscriber::builder()
.with_env_filter(EnvFilter::from_default_env())
.finish();
set_global_default(subscriber).expect("Failed to set subscriber");
LogTracer::init().expect("Failed to set logger");
let settings = Settings::new()?;
let _guard = sentry::init((
settings.sentry.address.clone(),
sentry::ClientOptions {
release: sentry::release_name!(),
..Default::default()
},
));
info!("Starting alpaca-data-relay");

run(settings).await
let res = run(settings).await;
if let Err(e) = res {
capture_anyhow(&e);
}
Ok(())
}
6 changes: 6 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ pub struct AlpacaSettings {
pub trade_updates: bool,
}

#[derive(Debug, Deserialize)]
pub struct SentrySettings {
pub address: String,
}

#[derive(Debug, Deserialize)]
pub struct Settings {
pub alpaca: AlpacaSettings,
pub kafka: KafkaSettings,
pub sentry: SentrySettings,
}

impl Settings {
Expand Down

0 comments on commit b130c86

Please sign in to comment.