This directory contains a collection of examples that demonstrate the use of the
tracing
ecosystem:
- tracing:
counters
: Implements a very simple metrics system to demonstrate how collectors can consume field values as typed data.sloggish
: A demoCollect
implementation that mimics the output ofslog-term
'sCompact
formatter.
- tracing-attributes:
attrs-basic
: A simple example of the#[instrument]
attribute.attrs-literal-field-names
: Demonstrates using literal field names rather than rust tokens..attrs-args
: An example implementing a simple recursive calculation of Fibonacci numbers, to demonstrate how the#[instrument]
attribute can record function arguments.
- tracing-subscriber:
fmt
: Demonstrates the use of thefmt
module intracing-subscriber
, which provides a collector implementation that logs traces to the console.fmt-stderr
: Demonstrates overriding the output stream used by thefmt
collector.fmt-custom-field
: Demonstrates overriding how thefmt
collector formats fields on spans and events.fmt-custom-event
: Demonstrates overriding how thefmt
collector formats events.fmt-multiple-writers.rs
: demonstrates howfmt::Subcriber
can write to multiple destinations (in this instance, stdout and a file) simultaneously.fmt-source-locations.rs
: demonstrates displaying source code locations withfmt::Subscriber
.subscriber-filter
: Demonstrates thetracing-subscriber::filter
module, which provides a subscriber which adds configurable filtering to a collector implementation.tower-load
: Demonstrates how dynamically reloadable filters can be used to debug a server under load in production.journald
: Demonstrates how to usefmt
andjournald
subscribers to output to both the terminal and the system journal.toggle-subscribers
: Demonstrates how subscribers can be wrapped with anOption
allowing them to be dynamically toggled.
- tracing-futures:
spawny-thing
: Demonstrates the use of the#[instrument]
attribute macro asynchronous functions.tokio-spawny-thing.rs
: Similar tospawny-thingy
, but with the additional demonstration instrumenting concurrent tasks created withtokio::spawn
.futures-proxy-server
: Demonstrates the use oftracing-futures
by implementing a simple proxy server, based on this example fromtokio
.async_fn
: Demonstrates how asynchronous functions can be instrumented.echo
: Demonstrates atracing
-instrumented variant of Tokio'secho
example.
- tracing-flame:
infero-flame
: Demonstrates the use oftracing-flame
to generate a flamegraph from spans.
- tracing-tower:
tower-client
: Demonstrates the use oftracing-tower
to instrument a simpletower
HTTP/1.1 client.tower-server
: Demonstrates the use oftracing-tower
to instrument a simpletower
HTTP/1.1 server.
- tracing-serde:
serde-yak-shave
: Demonstrates the use oftracing-serde
by implementing a collector that emits trace output as JSON.
- tracing-log:
hyper-echo
: Demonstrates howtracing-log
can be used to record unstructured logs from dependencies astracing
events, by instrumenting this example fromhyper
, and usingtracing-log
to record logs emitted byhyper
.