Skip to main content

Crate tracing_flat_json

Crate tracing_flat_json 

Source
Expand description

A simple tracing_subscriber::Layer emitting newline-delimited JSON, with all event and span fields flattened onto the top level JSON object. Similar to combining the json-subscriber options with_flattened_event and with_top_level_flattened_span_list, without the caveats about duplicate fields noted in the documentation for those options.

§Usage

use tracing_subscriber::prelude::*;

tracing_subscriber::Registry::default()
    .with(tracing_flat_json::FlatJsonLayer::new(std::io::stdout))
    .init();

§Feature Flags

§Output Format

Included:

  • timestamp (RFC3339 UTC)
  • level
  • trace_id (with feature tracing-opentelemetry)
  • code.file.path
  • code.line.number
  • event message
  • event fields, source code order
  • parent span fields, source code order, latest span first, root span last

Excluded:

  • span names
  • target
  • span_id
  • duplicate fields (only latest value for each field name)

Structs§

FlatJsonLayer
See the module-level documentation for usage.