Skip to content
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

ref(symbolicator): Replace log with tracing #534

Merged
merged 24 commits into from
Jan 31, 2022
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- Remove actix-web in favor of axum. This changes the web framework and also completely switches to the tokio 1 Runtime. ([#544](https://github.com/getsentry/symbolicator/pull/544))
- Search for all known types of debug companion files during symbolication, in case there exists for example an ELF debug companion for a PE. ([#555](https://github.com/getsentry/symbolicator/pull/555))
- Introduced the `custom_tags` config setting for metrics ([#569](https://github.com/getsentry/symbolicator/pull/569))
- Use the `tracing` crate for logging ([#534](https://github.com/getsentry/symbolicator/pull/534))

### Fixes

Expand Down
97 changes: 51 additions & 46 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions crates/symbolicator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ base64 = "0.13.0"
cadence = "0.27.0"
chrono = { version = "0.4.19", features = ["serde"] }
console = "0.15.0"
env_logger = "0.7.1"
filetime = "0.2.14"
flate2 = "1.0.0"
futures = "0.3.12"
Expand All @@ -25,12 +24,10 @@ humantime-serde = "1.0.1"
ipnetwork = "0.18.0"
jsonwebtoken = "7.2.0"
lazy_static = "1.4.0"
log = { version = "0.4.13", features = ["serde"] }
lru = "0.7.0"
num_cpus = "1.13.0"
minidump = "0.9.4"
parking_lot = "0.11.1"
pretty_env_logger = "0.4.0"
procspawn = { version = "0.10.0", features = ["backtrace", "json"] }
regex = "1.4.3"
reqwest = { git = "https://github.com/jan-auer/reqwest", tag = "v0.11.0", features = ["gzip", "json", "stream", "trust-dns"] }
Expand All @@ -49,7 +46,7 @@ symbolic = { git = "https://github.com/getsentry/symbolic", branch = "fix/demang
tempfile = "3.2.0"
thiserror = "1.0.26"
tracing = "0.1.29"
tracing-subscriber = { version = "0.3.5", default-features = false, features = ["std", "registry"] }
tracing-subscriber = { version = "0.3.6", features = ["tracing-log", "local-time", "env-filter", "json"] }
tokio = { version = "1.0.2", features = ["rt", "macros", "fs"] }
tokio-util = "0.6"
tower = "0.4"
Expand Down
18 changes: 9 additions & 9 deletions crates/symbolicator/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Cache {
}

pub fn cleanup(&self) -> Result<()> {
log::info!("Cleaning up cache: {}", self.name);
tracing::info!("Cleaning up cache: {}", self.name);
let cache_dir = self.cache_dir.clone().ok_or_else(|| {
anyhow!("no caching configured! Did you provide a path to your config file?")
})?;
Expand All @@ -295,7 +295,7 @@ impl Cache {
let entries = match catch_not_found(|| read_dir(directory))? {
Some(x) => x,
None => {
log::warn!("Directory not found");
tracing::warn!("Directory not found");
return Ok(());
}
};
Expand All @@ -308,7 +308,7 @@ impl Cache {
} else if let Err(e) = self.try_cleanup_path(&path) {
sentry::with_scope(
|scope| scope.set_extra("path", path.display().to_string().into()),
|| log::error!("Failed to clean cache file: {:?}", e),
|| tracing::error!("Failed to clean cache file: {:?}", e),
);
}
}
Expand All @@ -318,10 +318,10 @@ impl Cache {
}

fn try_cleanup_path(&self, path: &Path) -> Result<()> {
log::trace!("Checking {}", path.display());
tracing::trace!("Checking {}", path.display());
anyhow::ensure!(path.is_file(), "not a file");
if catch_not_found(|| self.check_expiry(path))?.is_none() {
log::debug!("Removing {}", path.display());
tracing::debug!("Removing {}", path.display());
catch_not_found(|| remove_file(path))?;
}

Expand All @@ -348,7 +348,7 @@ impl Cache {
// of last use.
let metadata = path.metadata()?;

log::trace!("File length: {}", metadata.len());
tracing::trace!("File length: {}", metadata.len());

let expiration_strategy = expiration_strategy(&self.cache_config, path)?;

Expand All @@ -367,7 +367,7 @@ impl Cache {
};

if created_at < self.start_time || retry_malformed {
log::trace!("Created at is older than start time");
tracing::trace!("Created at is older than start time");
return Err(io::ErrorKind::NotFound.into());
}
}
Expand Down Expand Up @@ -454,7 +454,7 @@ fn expiration_strategy(cache_config: &CacheConfig, path: &Path) -> io::Result<Ex
let mut buf = vec![0; readable_amount];

file.read_exact(&mut buf)?;
log::trace!("First {} bytes: {:?}", buf.len(), buf);
tracing::trace!("First {} bytes: {:?}", buf.len(), buf);

let strategy = match CacheStatus::from_content(&buf) {
CacheStatus::Positive => ExpirationStrategy::None,
Expand Down Expand Up @@ -620,7 +620,7 @@ impl Caches {
for result in results {
if let Err(err) = result {
let stderr: &dyn std::error::Error = &*err;
log::error!("Failed to cleanup cache: {}", LogError(stderr));
tracing::error!("Failed to cleanup cache: {}", LogError(stderr));
if first_error.is_none() {
first_error = Some(err);
}
Expand Down
15 changes: 5 additions & 10 deletions crates/symbolicator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::path::{Path, PathBuf};

use anyhow::{Context, Result};
use structopt::StructOpt;
use tracing_subscriber::prelude::*;

use crate::cache;
use crate::config::Config;
Expand Down Expand Up @@ -72,30 +71,26 @@ pub fn execute() -> Result<()> {
..Default::default()
});

tracing_subscriber::Registry::default()
.with(sentry::integrations::tracing::layer())
.init();

logging::init_logging(&config);
if let Some(ref statsd) = config.metrics.statsd {
let mut tags = config.metrics.custom_tags.clone();

if let Some(hostname_tag) = config.metrics.hostname_tag.clone() {
if tags.contains_key(&hostname_tag) {
log::warn!(
tracing::warn!(
"tag {} defined both as hostname tag and as a custom tag",
hostname_tag
);
}
if let Some(hostname) = hostname::get().ok().and_then(|s| s.into_string().ok()) {
tags.insert(hostname_tag, hostname);
} else {
log::error!("could not read host name");
tracing::error!("could not read host name");
}
};
if let Some(environment_tag) = config.metrics.environment_tag.clone() {
if tags.contains_key(&environment_tag) {
log::warn!(
tracing::warn!(
"tag {} defined both as environment tag and as a custom tag",
environment_tag
);
Expand All @@ -104,7 +99,7 @@ pub fn execute() -> Result<()> {
{
tags.insert(environment_tag, environment);
} else {
log::error!("environment name not available");
tracing::error!("environment name not available");
}
};

Expand All @@ -113,7 +108,7 @@ pub fn execute() -> Result<()> {

procspawn::ProcConfig::new()
.config_callback(|| {
log::trace!("[procspawn] initializing in sub process");
tracing::trace!("[procspawn] initializing in sub process");
metric!(counter("procspawn.init") += 1);
})
.init();
Expand Down
Loading