Skip to content

Commit

Permalink
Merge branch 'main' into rustls
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Apr 11, 2023
2 parents 2312cd2 + 078c16c commit a0ae1e2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions shotover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typetag.workspace = true
thiserror = "1.0"
anyhow.workspace = true
backtrace = "0.3.66"
backtrace-ext = "0.2"

# Parsers
cql3-parser = "0.3.2"
Expand Down
9 changes: 2 additions & 7 deletions shotover/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ impl TracingState {
.with_env_filter(env_filter)
.with_filter_reloading();
let handle = ReloadHandle::Json(builder.reload_handle());
// To avoid unit tests that run in the same excutable from blowing up when they try to reinitialize tracing we ignore the result returned by try_init.
// Currently the implementation of try_init will only fail when it is called multiple times.
builder.try_init().ok();
builder.init();
handle
}
LogFormat::Human => {
Expand All @@ -245,13 +243,10 @@ impl TracingState {
.with_env_filter(env_filter)
.with_filter_reloading();
let handle = ReloadHandle::Human(builder.reload_handle());
builder.try_init().ok();
builder.init();
handle
}
};
if let LogFormat::Json = format {
crate::tracing_panic_handler::setup();
}

// When in json mode we need to process panics as events instead of printing directly to stdout.
// This is so that:
Expand Down
34 changes: 3 additions & 31 deletions shotover/src/tracing_panic_handler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use backtrace::{Backtrace, BacktraceFmt, BacktraceFrame, BytesOrWideString, PrintFmt};
use backtrace::{Backtrace, BacktraceFmt, BytesOrWideString, PrintFmt};
use std::fmt;

pub fn setup() {
Expand Down Expand Up @@ -49,37 +49,9 @@ impl fmt::Display for BacktraceFormatter {

let mut f = BacktraceFmt::new(f, PrintFmt::Short, &mut print_path);
f.add_context()?;
let mut include_frames = false;
for frame in self.0.frames() {
if frame_is_named(
frame,
"std::sys_common::backtrace::__rust_begin_short_backtrace",
) {
break;
}

if include_frames {
f.frame().backtrace_frame(frame)?;
}

if frame_is_named(
frame,
"std::sys_common::backtrace::__rust_end_short_backtrace",
) {
include_frames = true;
}
for (frame, _) in backtrace_ext::short_frames_strict(&self.0) {
f.frame().backtrace_frame(frame)?;
}
f.finish()
}
}

fn frame_is_named(frame: &BacktraceFrame, name: &str) -> bool {
for symbol in frame.symbols() {
if let Some(full_name) = symbol.name() {
if format!("{}", full_name).starts_with(name) {
return true;
}
}
}
false
}

0 comments on commit a0ae1e2

Please sign in to comment.