Lines Matching full:tracing
1 ![Tracing — Structured, application-level diagnostics][splash]
3 [splash]: https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/splash.svg
5 # tracing chapter
7 Application-level tracing for Rust.
18 [crates-badge]: https://img.shields.io/crates/v/tracing.svg
19 [crates-url]: https://crates.io/crates/tracing
20 [docs-badge]: https://docs.rs/tracing/badge.svg
21 [docs-url]: https://docs.rs/tracing
23 [docs-master-url]: https://tracing-rs.netlify.com/tracing
26 [actions-badge]: https://github.com/tokio-rs/tracing/workflows/CI/badge.svg
27 [actions-url]:https://github.com/tokio-rs/tracing/actions?query=workflow%3ACI
33 `tracing` is a framework for instrumenting Rust programs to collect
39 trace the logic flow. `tracing` expands upon logging-style diagnostics by
42 in `tracing` has a beginning and end time, may be entered and exited by the
44 addition, `tracing` spans are *structured*, with the ability to record typed
47 The `tracing` crate provides the APIs necessary for instrumenting libraries
58 idiomatic `tracing`.)
63 implementation compatible with `tracing`. A `Subscriber` implements a way of
64 … as by logging it to standard output. [`tracing_subscriber`](https://docs.rs/tracing-subscriber/)'s
65 [`fmt` module](https://docs.rs/tracing-subscriber/0.3/tracing_subscriber/fmt/index.html) provides r…
66 Additionally, `tracing-subscriber` is able to consume messages emitted by `log`-instrumented librar…
71 use tracing::{info, Level};
83 tracing::subscriber::set_global_default(subscriber)
100 tracing = "0.1"
101 tracing-subscriber = "0.2.0"
110 use tracing::{info, Level};
121 tracing::subscriber::with_default(subscriber, || {
135 executable using the `tracing` crate's macros.
139 Libraries should only rely on the `tracing` crate and use the provided macros
144 use tracing::{debug, error, info, span, warn, Level};
146 // the `#[tracing::instrument]` attribute creates and enters a span
149 #[tracing::instrument]
159 // note that this is intended to demonstrate `tracing`'s features, not idiomatic
202 tracing = "0.1"
223 let _s = tracing::span!(...).entered();
232 For more details, see [the documentation on closing spans](https://tracing.rs/tracing/span/index.ht…
235 [`Future::instrument`](https://docs.rs/tracing/latest/tracing/trait.Instrument.html#method.instrume…
238 use tracing::Instrument;
245 .instrument(tracing::info_span!("my_future"))
253 [`#[instrument]`](https://docs.rs/tracing/0.1.37/tracing/attr.instrument.html)
257 use tracing::{info, instrument};
289 use tracing::{span, Level};
300 The [`#[instrument]`](https://docs.rs/tracing/0.1.37/tracing/attr.instrument.html) attribute macro
304 use tracing::{instrument};
310 tracing::info!("inside my_function!");
320 use tracing::{event, Level};
325 Users of the [`log`] crate should note that `tracing` exposes a set of macros for
328 crate. Often, the process of converting a project to use `tracing` can begin
333 Tracing is built against the latest stable release. The minimum supported
334 version is 1.42. The current Tracing version is not guaranteed to build on Rust
337 Tracing follows the same compiler support policies as the rest of the Tokio
349 In addition to `tracing` and `tracing-core`, the [`tokio-rs/tracing`] repository
350 contains several additional crates designed to be used with the `tracing` ecosystem.
357 - [`tracing-futures`] provides a compatibility layer with the `futures`
359 - [`tracing-subscriber`] provides `Subscriber` implementations and
363 - [`tracing-log`] provides a compatibility layer with the [`log`] crate,
364 allowing log messages to be recorded as `tracing` `Event`s within the
365 trace tree. This is useful when a project using `tracing` have
367 `tracing-subscriber`'s `FmtSubscriber`, you don't need to depend on
368 `tracing-log` directly.
373 - [`tracing-timing`] implements inter-event timing metrics on top of `tracing`.
375 `tracing` events and generates histograms.
376 - [`tracing-opentelemetry`] provides a subscriber for emitting traces to
377 [OpenTelemetry]-compatible distributed tracing systems.
378 - [`tracing-honeycomb`] Provides a layer that reports traces spanning multiple machines to [honeyco…
379 - [`tracing-distributed`] Provides a generic implementation of a layer that reports traces spanning…
380 - [`tracing-actix`] provides `tracing` integration for the `actix` actor
382 - [`tracing-gelf`] implements a subscriber for exporting traces in Greylog
384 - [`tracing-coz`] provides integration with the [coz] causal profiler
386 - [`test-log`] takes care of initializing `tracing` for tests, based on
388 - [`tracing-unwrap`] provides convenience methods to report failed unwraps on `Result` or `Option` …
389 - [`diesel-tracing`] provides integration with [`diesel`] database connections.
390 - [`tracing-tracy`] provides a way to collect [Tracy] profiles in instrumented
392 - [`tracing-elastic-apm`] provides a layer for reporting traces to [Elastic APM].
393 - [`tracing-etw`] provides a layer for emitting Windows [ETW] events.
394 - [`tracing-fluent-assertions`] provides a fluent assertions-style testing
395 framework for validating the behavior of `tracing` spans.
396 - [`sentry-tracing`] provides a layer for reporting events and traces to [Sentry].
397 - [`tracing-loki`] provides a layer for shipping logs to [Grafana Loki].
398 - [`tracing-logfmt`] provides a layer that formats events and spans into the logfmt format.
400 If you're the maintainer of a `tracing` ecosystem crate not listed above,
403 [`tracing-timing`]: https://crates.io/crates/tracing-timing
404 [`tracing-opentelemetry`]: https://crates.io/crates/tracing-opentelemetry
406 [`tracing-honeycomb`]: https://crates.io/crates/tracing-honeycomb
407 [`tracing-distributed`]: https://crates.io/crates/tracing-distributed
409 [`tracing-actix`]: https://crates.io/crates/tracing-actix
410 [`tracing-gelf`]: https://crates.io/crates/tracing-gelf
411 [`tracing-coz`]: https://crates.io/crates/tracing-coz
414 [`tracing-unwrap`]: https://docs.rs/tracing-unwrap
416 [`diesel-tracing`]: https://crates.io/crates/diesel-tracing
417 [`tracing-tracy`]: https://crates.io/crates/tracing-tracy
419 [`tracing-elastic-apm`]: https://crates.io/crates/tracing-elastic-apm
421 [`tracing-etw`]: https://github.com/microsoft/tracing-etw
422 [ETW]: https://docs.microsoft.com/en-us/windows/win32/etw/about-event-tracing
423 [`tracing-fluent-assertions`]: https://crates.io/crates/tracing-fluent-assertions
424 [`sentry-tracing`]: https://crates.io/crates/sentry-tracing
426 [`tracing-loki`]: https://crates.io/crates/tracing-loki
428 [`tracing-logfmt`]: https://crates.io/crates/tracing-logfmt
431 undergoing active development. They may be less stable than `tracing` and
432 `tracing-core`.
435 [`tokio-rs/tracing`]: https://github.com/tokio-rs/tracing
436 [`tracing-futures`]: https://github.com/tokio-rs/tracing/tree/master/tracing-futures
437 [`tracing-subscriber`]: https://github.com/tokio-rs/tracing/tree/master/tracing-subscriber
438 [`tracing-log`]: https://github.com/tokio-rs/tracing/tree/master/tracing-log
440 [`FmtSubscriber`]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Subscrib…
441 [`examples`]: https://github.com/tokio-rs/tracing/tree/master/examples
445 Tracing is built against the latest stable release. The minimum supported
446 version is 1.49. The current Tracing version is not guaranteed to build on Rust
449 Tracing follows the same compiler support policies as the rest of the Tokio