mirror of
https://github.com/tokio-rs/tracing.git
synced 2026-03-14 01:57:55 +00:00
### Fixed - **fmt**: Fixed compilation failure on MSRV when the `chrono` feature is disabled (#844) ### Added - **fmt**: Span lookup methods defined by `layer::Context` are now also provided by `FmtContext` (#834)
Tracing Examples
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 subscribers can consume field values as typed data.sloggish: A demoSubscriberimplementation that mimics the output ofslog-term'sCompactformatter.
- tracing-attributes:
attrs-basic: A simple example of the#[instrument]attribute.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 thefmtmodule intracing-subscriber, which provides a subscriber implementation that logs traces to the console.fmt-stderr: Demonstrates overriding the output stream used by thefmtsubscriber.fmt-custom-field: Demonstrates overriding how thefmtsubscriber formats fields on spans and events.fmt-custom-event: Demonstrates overriding how thefmtsubscriber formats events.subscriber-filter: Demonstrates thetracing-subscriber::filtermodule, which provides a layer which adds configurable filtering to a subscriber implementation.tower-load: Demonstrates how dynamically reloadable filters can be used to debug a server under load in production.journald: Demonstrates how to usefmtandjournaldlayers to output to both the terminal and the system journal.
- 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-futuresby 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'sechoexample.
- tracing-flame:
infero-flame: Demonstrates the use oftracing-flameto generate a flamegraph from spans.
- tracing-tower:
tower-client: Demonstrates the use oftracing-towerto instrument a simpletowerHTTP/1.1 client.tower-server: Demonstrates the use oftracing-towerto instrument a simpletowerHTTP/1.1 server.
- tracing-serde:
serde-yak-shave: Demonstrates the use oftracing-serdeby implementing a subscriber that emits trace output as JSON.
- tracing-log:
hyper-echo: Demonstrates howtracing-logcan be used to record unstructured logs from dependencies astracingevents, by instrumenting this example fromhyper, and usingtracing-logto record logs emitted byhyper.
- tracing-opentelemetry:
opentelemetry: Demonstrates howtracing-opentelemetrycan be used to export and visualizetracingspan data.opentelemetry-remote-context: Demonstrates howtracing-opentelemetrycan be used to extract and inject remote context when traces span multiple systems.