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

Adopt Tracing #1410

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
f5a8681
WIP
hawkw Jul 21, 2020
debb008
filtering, nicer formatting
hawkw Jul 21, 2020
e0a0bfd
more trace
hawkw Jul 21, 2020
6e0e902
fix filtering
hawkw Jul 21, 2020
47540a9
mounting works
hawkw Jul 21, 2020
88cee8c
WIP
hawkw Jul 22, 2020
d920738
skip span names for "rocket-ier" formatitng
hawkw Jul 22, 2020
bce8f14
this is cute, right?
hawkw Jul 22, 2020
e3398e5
fix contrib
hawkw Jul 23, 2020
86c5ef5
use span names if there's no message
hawkw Jul 23, 2020
88feb8e
start removing underscore macros
hawkw Jul 23, 2020
cbe5581
less obnoxious bold, nicer debug/trace
hawkw Jul 23, 2020
43c95db
don't constantly screw up colors
hawkw Jul 23, 2020
1eec8f6
unpatch
hawkw Jul 25, 2020
2589dee
add docs & reexports
hawkw Aug 11, 2020
533d792
cleanup, remove logger module
hawkw Aug 11, 2020
e7b55d7
whoops
hawkw Aug 11, 2020
2dbd927
Merge branch 'master' into eliza/trace
hawkw Aug 11, 2020
4bd3da2
trailing whitespace
hawkw Aug 13, 2020
9905887
trailing whitespace again
hawkw Aug 13, 2020
118e13e
fixup
hawkw Aug 13, 2020
03533ce
use `macro_use` imports everywhere
hawkw Aug 13, 2020
9e6adc6
use spans for all indentation-based messages
hawkw Aug 13, 2020
ec5066b
update codegen
hawkw Aug 13, 2020
6144caa
add spans to generated catcher/route fns
hawkw Aug 13, 2020
e1b67db
make catcher spans info
hawkw Aug 13, 2020
cd124d8
bold span names when no message is present
hawkw Aug 13, 2020
bc492ba
add more info to generated spans
hawkw Aug 14, 2020
88e965e
Replace `log` with `tracing` and `tracing-subscriber`.
hawkw Oct 31, 2020
6fbbf94
style: remove most usage of span.enter()
jebrosen Nov 1, 2020
c8e4b6b
fix: macros are weird sometimes
jebrosen Nov 1, 2020
eeeab88
fix: use of moved value
jebrosen Nov 1, 2020
41237b6
Merge remote-tracking branch 'jebrosen/adopt-tracing' into eliza/trace
hawkw Nov 2, 2020
9f86214
allow libtest to capture trace logs
hawkw Nov 2, 2020
9e95437
remove workaround
hawkw Nov 2, 2020
9776ca3
remove workarounds, add `log` compat
hawkw Nov 3, 2020
fa5f30d
examples for a custom subscriber, env_logger
hawkw Nov 3, 2020
73ca07c
Merge branch 'master' into eliza/trace
hawkw Nov 4, 2020
e68d66d
use structured fields in more places
hawkw Nov 4, 2020
4e9a308
post-rebase fixup
hawkw Nov 4, 2020
a868cab
use `in_scope` for errors
hawkw Nov 4, 2020
cb1b024
allow adding directives to Rocket's filter
hawkw Nov 4, 2020
6de1180
make examples a little fancier
hawkw Nov 4, 2020
4ddaedf
fix trace in contrib
hawkw Nov 4, 2020
0025a58
propagate spans to spawned threads
hawkw Nov 4, 2020
f15d432
put all request processing inside request span
hawkw Nov 4, 2020
dd77f67
add another span in 'Fairings::pretty_print_counts'
jebrosen Nov 4, 2020
d5006de
feat: use rocket::trace::info in fairings, manual_routes examples
jebrosen Nov 4, 2020
4bf5f33
remove trailing whitespace
jebrosen Nov 5, 2020
50a224d
fix(codegen): log parameter names in a way that will work for any kin…
jebrosen Nov 12, 2020
55faca7
fix compile error in manual_routes example
jebrosen Nov 12, 2020
732a613
fix(test): missing semicolon
jebrosen Nov 12, 2020
8dba51d
feat: rework log output formatting
jebrosen Nov 13, 2020
39ae1d5
feat: print request IDs
jebrosen Nov 13, 2020
910ad1c
feat/experiment: remove connection span, making 'request' the top-lev…
jebrosen Nov 13, 2020
63e0ef3
handle `log` metadata properly
hawkw Nov 16, 2020
8ac9625
use tracing instead of log in http
jebrosen Nov 15, 2020
2f098a7
call Paint::disable in more cases of 'tracing' initialization failure
jebrosen Nov 17, 2020
2cfad83
add new log level 'support'
jebrosen Nov 18, 2020
d69340c
fixup: add string form to description of 'support' to make consistent…
jebrosen Nov 19, 2020
0d506c1
Use 'in_scope' instead of 'enter' in most places.
jebrosen Nov 19, 2020
c19799b
fix: under feature="log", skip formatting of fields whose names start…
jebrosen Nov 21, 2020
85f2e5b
fix: test the 'log' feature individually
jebrosen Nov 21, 2020
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
16 changes: 8 additions & 8 deletions core/lib/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ impl Config {
pub(crate) fn pretty_print(&self, profile: &Profile) {
use crate::trace::PaintExt;

let span = info_span!("configured", "{}Configured for {}", Paint::emoji("🔧 "), profile);
let span = info_span!(target: "rocket::support", "configured", "{}Configured for {}", Paint::emoji("🔧 "), profile);
let _e = span.enter();

info!(address = %&self.address);
info!(port = %&self.port);
info!(workers = %self.workers);
info!(log_level = %self.log_level);
info!(secret_key = ?&self.secret_key);
info!(limits = %&self.limits);
info!(cli_colors = %&self.cli_colors);
info!(target: "rocket::support", address = %&self.address);
info!(target: "rocket::support", port = %&self.port);
info!(target: "rocket::support", workers = %self.workers);
info!(target: "rocket::support", log_level = %self.log_level);
info!(target: "rocket::support", secret_key = ?&self.secret_key);
info!(target: "rocket::support", limits = %&self.limits);
info!(target: "rocket::support", cli_colors = %&self.cli_colors);

let ka = self.keep_alive;
if ka > 0 {
Expand Down
10 changes: 8 additions & 2 deletions core/lib/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ pub mod prelude {
pub enum LogLevel {
/// Only shows errors and warnings: `"critical"`.
Critical,
/// Shows errors, warnings, and some informational messages that are likely
/// to be relevant when troubleshooting (such as configuration).
jebrosen marked this conversation as resolved.
Show resolved Hide resolved
Support,
/// Shows everything except debug and trace information: `"normal"`.
Normal,
/// Shows everything: `"debug"`.
Expand All @@ -236,6 +239,7 @@ impl LogLevel {
fn as_str(&self) -> &str {
match self {
LogLevel::Critical => "critical",
LogLevel::Support => "support",
LogLevel::Normal => "normal",
LogLevel::Debug => "debug",
LogLevel::Off => "off",
Expand All @@ -249,10 +253,11 @@ impl FromStr for LogLevel {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let level = match &*s.to_ascii_lowercase() {
"critical" => LogLevel::Critical,
"support" => LogLevel::Support,
"normal" => LogLevel::Normal,
"debug" => LogLevel::Debug,
"off" => LogLevel::Off,
_ => return Err("a log level (off, debug, normal, critical)"),
_ => return Err("a log level (off, debug, normal, support, critical)"),
};

Ok(level)
Expand Down Expand Up @@ -349,6 +354,7 @@ impl<'de> Deserialize<'de> for LogLevel {
pub fn filter_layer(level: LogLevel) -> Filter {
let filter_str = match level {
LogLevel::Critical => "warn,hyper=off,rustls=off",
LogLevel::Support => "warn,rocket::support=info,hyper=off,rustls=off",
LogLevel::Normal => "info,hyper=off,rustls=off",
LogLevel::Debug => "trace",
LogLevel::Off => "off",
Expand Down Expand Up @@ -650,7 +656,7 @@ fn try_init_log(filter: LogLevel) -> Result<(), impl std::error::Error> {
// will already be collected.
.ignore_all(vec!["rocket", "hyper", "tracing::span"]);
let builder = match filter {
LogLevel::Critical => builder
LogLevel::Critical | LogLevel::Support => builder
.ignore_crate("rustls")
// Set the max level for all `log` records to Warn. Rocket's
// `launch` events will be collected by the native `tracing`
Expand Down