Skip to content

Commit

Permalink
storcon: use tracing for logging panics (#8734)
Browse files Browse the repository at this point in the history
this gives spans for panics, and does not globber loki output by writing
to stderr while all of the other logging is to stdout.

See: #3475
  • Loading branch information
koivunej authored Aug 15, 2024
1 parent 52641eb commit 24d347f
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions storage_controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,26 @@ async fn migration_run(database_url: &str) -> anyhow::Result<()> {
}

fn main() -> anyhow::Result<()> {
let default_panic = std::panic::take_hook();
logging::init(
LogFormat::Plain,
logging::TracingErrorLayerEnablement::Disabled,
logging::Output::Stdout,
)?;

// log using tracing so we don't get confused output by default hook writing to stderr
utils::logging::replace_panic_hook_with_tracing_panic_hook().forget();

let _sentry_guard = init_sentry(Some(GIT_VERSION.into()), &[]);

let hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |info| {
default_panic(info);
// let sentry send a message (and flush)
// and trace the error
hook(info);

std::process::exit(1);
}));

let _sentry_guard = init_sentry(Some(GIT_VERSION.into()), &[]);

tokio::runtime::Builder::new_current_thread()
// We use spawn_blocking for database operations, so require approximately
// as many blocking threads as we will open database connections.
Expand All @@ -217,12 +229,6 @@ fn main() -> anyhow::Result<()> {
async fn async_main() -> anyhow::Result<()> {
let launch_ts = Box::leak(Box::new(LaunchTimestamp::generate()));

logging::init(
LogFormat::Plain,
logging::TracingErrorLayerEnablement::Disabled,
logging::Output::Stdout,
)?;

preinitialize_metrics();

let args = Cli::parse();
Expand Down

1 comment on commit 24d347f

@github-actions
Copy link

@github-actions github-actions bot commented on 24d347f Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2252 tests run: 2172 passed, 1 failed, 79 skipped (full report)


Failures on Postgres 14

  • test_sharding_autosplit[github-actions-selfhosted]: release
# Run all failed tests locally:
scripts/pytest -vv -n $(nproc) -k "test_sharding_autosplit[release-pg14-github-actions-selfhosted]"

Code coverage* (full report)

  • functions: 32.4% (7216 of 22266 functions)
  • lines: 50.4% (58279 of 115732 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
24d347f at 2024-08-15T15:42:04.032Z :recycle:

Please sign in to comment.