Skip to content

Commit ce01478

Browse files
committed
tracing: Use json-subscriber crate for JSON logging
This allows us to flatten the span fields, which makes them a lot easier to use within Datadog.
1 parent db885d4 commit ce01478

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Cargo.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ hyper = { version = "=1.5.0", features = ["client", "http1"] }
7979
indexmap = { version = "=2.6.0", features = ["serde"] }
8080
indicatif = "=0.17.8"
8181
ipnetwork = "=0.20.0"
82+
json-subscriber = "=0.2.1"
8283
tikv-jemallocator = { version = "=0.6.0", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
8384
lettre = { version = "=0.11.9", default-features = false, features = ["file-transport", "smtp-transport", "native-tls", "hostname", "builder"] }
8485
minijinja = "=2.3.1"

src/util/tracing.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ fn init_with_default_level(level: LevelFilter) {
2929
.unwrap_or_default();
3030

3131
let log_layer = match log_format.as_deref() {
32-
Some("json") => tracing_subscriber::fmt::layer()
33-
.json()
32+
Some("json") => json_subscriber::fmt::layer()
33+
.flatten_event(true)
34+
.with_flat_span_list(true)
3435
.with_filter(env_filter)
3536
.boxed(),
3637
_ => tracing_subscriber::fmt::layer()

0 commit comments

Comments
 (0)