Skip to content

sentry: Enable tracing feature #3919

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 5, 2021
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
12 changes: 12 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ rand = "0.8"
reqwest = { version = "0.11", features = ["blocking", "gzip", "json"] }
scheduled-thread-pool = "0.2.0"
semver = { version = "1.0.3", features = ["serde"] }
sentry = "0.23.0"
sentry = { version = "0.23.0", features = ["tracing"] }
serde = { version = "1.0.0", features = ["derive"] }
serde_json = "1.0.0"
sha2 = "0.9"
Expand Down
17 changes: 15 additions & 2 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![warn(clippy::all, rust_2018_idioms)]

use cargo_registry::{metrics::LogEncoder, util::errors::AppResult, App, Env};
use std::{fs::File, process::Command, sync::Arc, time::Duration};
use std::{env, fs::File, process::Command, sync::Arc, time::Duration};

use conduit_hyper::Service;
use futures_util::future::FutureExt;
Expand All @@ -10,14 +10,27 @@ use reqwest::blocking::Client;
use std::io::Write;
use tokio::io::AsyncWriteExt;
use tokio::signal::unix::{signal, SignalKind};
use tracing::Level;
use tracing_subscriber::{filter, prelude::*};

const CORE_THREADS: usize = 4;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let _sentry = cargo_registry::sentry::init();

// Initialize logging
tracing_subscriber::fmt::init();

let log_filter = env::var("RUST_LOG")
.unwrap_or_default()
.parse::<filter::Targets>()
.expect("Invalid RUST_LOG value");

let sentry_filter = filter::Targets::new().with_default(Level::INFO);

tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_filter(log_filter))
.with(sentry::integrations::tracing::layer().with_filter(sentry_filter))
.init();

let config = cargo_registry::config::Server::default();
let env = config.env();
Expand Down