Lines Matching full:tracing
5 //! `tracing` is a framework for instrumenting Rust programs to collect
11 //! trace the logic flow. `tracing` expands upon logging-style diagnostics by
14 //! in `tracing` has a beginning and end time, may be entered and exited by the
16 //! addition, `tracing` spans are *structured*, with the ability to record typed
19 //! The `tracing` crate provides the APIs necessary for instrumenting libraries
27 //! The core of `tracing`'s API is composed of _spans_, _events_ and
32 //! To record the flow of execution through a program, `tracing` introduces the
42 //! use tracing::{span, Level};
73 //! use tracing::{event, span, Level};
119 //! tracing = "0.1"
136 //! use tracing::{span, Level};
152 //! add `tracing` spans to functions. A function annotated with `#[instrument]`
161 //! use tracing::{Level, event, instrument};
173 //! For functions which don't have built-in tracing support and can't have
180 //! use tracing::info_span;
196 //! [examples]: https://github.com/tokio-rs/tracing/tree/master/examples
204 //! use tracing::{event, Level};
225 //! # use tracing::{span, event, Level};
232 //! # use tracing::{span, event, Level};
248 //! # use tracing::{event, Level};
261 //! # use tracing::{span, Level};
273 //! # use tracing::{span, Level};
284 //! # use tracing::{span, Level};
304 //! # use tracing::{span, Level};
316 //! # use tracing::{event, Level};
330 //! event!(Level::TRACE, greeting = tracing::field::debug(&my_struct));
337 //! # use tracing::{event, Level};
350 //! event!(Level::TRACE, greeting = tracing::field::display(&my_struct.field));
357 //! # use tracing::{event, Level};
377 //! use tracing::{trace_span, field};
392 //! # use tracing::Level;
414 //! # use tracing::{event, Level};
445 //! `tracing` also offers a number of macros with preset verbosity levels.
470 //! Users of the [`log`] crate should note that `tracing` exposes a set of
474 //! use `tracing` can begin with a simple drop-in replacement.
480 //! use tracing::{debug, error, info, span, warn, Level};
482 //! // the `#[tracing::instrument]` attribute creates and enters a span
485 //! #[tracing::instrument]
495 //! // note that this is intended to demonstrate `tracing`'s features, not idiomatic
538 //! Libraries should link only to the `tracing` crate, and use the provided
545 //! implementation compatible with `tracing`. A `Subscriber` implements a
555 //! extern crate tracing;
557 //! # use tracing::{span::{Id, Attributes, Record}, Metadata};
558 //! # impl tracing::Subscriber for FooSubscriber {
561 //! # fn event(&self, _: &tracing::Event) {}
573 //! tracing::subscriber::set_global_default(my_subscriber)
574 //! .expect("setting tracing default failed");
595 //! # use tracing::{span::{Id, Attributes, Record}, Metadata};
596 //! # impl tracing::Subscriber for FooSubscriber {
599 //! # fn event(&self, _: &tracing::Event) {}
612 //! tracing::subscriber::with_default(my_subscriber, || {
626 //! executable using the `tracing` crate's macros.
631 //! While `tracing` builds upon `log`'s foundation with richer structured
635 //! `tracing` provides multiple forms of interoperability with `log`: `tracing`
637 //! `tracing` [`Subscriber`]s to consume `log` records as `tracing` [`Event`]s.
643 //! enabled, if no `tracing` `Subscriber` is active, invoking an event macro or
646 //! consumed by applications using `tracing` *or* `log`, without paying the
647 //! additional overhead of emitting both forms of diagnostics when `tracing` is
651 //! even if a `tracing` `Subscriber` _is_ set. This is intended to be used in
653 //! and `tracing` is used only to record other forms of diagnostics (such as
654 //! metrics, profiling, or distributed tracing data). Unlike the "log" feature,
668 //! under a separate `log` target, "tracing::span" (and its sub-target,
669 //! "tracing::span::active", for the logs on entering and exiting a span), which
671 //! `tracing`.
675 //! The [`tracing-log`] crate provides a compatibility layer which
676 //! allows a `tracing` [`Subscriber`] to consume `log` records as though they
677 //! were `tracing` [events]. This allows applications using `tracing` to record
682 //! [log-tracer]: https://docs.rs/tracing-log/latest/tracing_log/#convert-log-records-to-tracing-ev…
686 //! In addition to `tracing` and `tracing-core`, the [`tokio-rs/tracing`] repository
687 //! contains several additional crates designed to be used with the `tracing` ecosystem.
694 //! - [`tracing-futures`] provides a compatibility layer with the `futures`
696 //! - [`tracing-subscriber`] provides `Subscriber` implementations and
700 //! - [`tracing-log`] provides a compatibility layer with the [`log`] crate,
701 //! allowing log messages to be recorded as `tracing` `Event`s within the
702 //! trace tree. This is useful when a project using `tracing` have
704 //! `tracing-subscriber`'s `FmtSubscriber`, you don't need to depend on
705 //! `tracing-log` directly.
706 //! - [`tracing-appender`] provides utilities for outputting tracing data,
712 //! - [`tracing-timing`] implements inter-event timing metrics on top of `tracing`.
714 //! `tracing` events and generates histograms.
715 //! - [`tracing-opentelemetry`] provides a subscriber for emitting traces to
716 //! [OpenTelemetry]-compatible distributed tracing systems.
717 //! - [`tracing-honeycomb`] Provides a layer that reports traces spanning multiple machines to [ho…
718 //! - [`tracing-distributed`] Provides a generic implementation of a layer that reports traces spa…
719 //! - [`tracing-actix-web`] provides `tracing` integration for the `actix-web` web framework.
720 //! - [`tracing-actix`] provides `tracing` integration for the `actix` actor
722 //! - [`tracing-gelf`] implements a subscriber for exporting traces in Greylog
724 //! - [`tracing-coz`] provides integration with the [coz] causal profiler
726 //! - [`tracing-bunyan-formatter`] provides a layer implementation that reports events and spans
728 //! - [`tracing-wasm`] provides a `Subscriber`/`Layer` implementation that reports
730 //! - [`tracing-web`] provides a layer implementation of level-aware logging of events
732 //! - [`tide-tracing`] provides a [tide] middleware to trace all incoming requests and responses.
733 //! - [`test-log`] takes care of initializing `tracing` for tests, based on
735 //! - [`tracing-unwrap`] provides convenience methods to report failed unwraps
737 //! - [`diesel-tracing`] provides integration with [`diesel`] database connections.
738 //! - [`tracing-tracy`] provides a way to collect [Tracy] profiles in instrumented
740 //! - [`tracing-elastic-apm`] provides a layer for reporting traces to [Elastic APM].
741 //! - [`tracing-etw`] provides a layer for emitting Windows [ETW] events.
742 //! - [`tracing-fluent-assertions`] provides a fluent assertions-style testing
743 //! framework for validating the behavior of `tracing` spans.
744 //! - [`sentry-tracing`] provides a layer for reporting events and traces to [Sentry].
745 //! - [`tracing-forest`] provides a subscriber that preserves contextual coherence by
747 //! - [`tracing-loki`] provides a layer for shipping logs to [Grafana Loki].
748 //! - [`tracing-logfmt`] provides a layer that formats events and spans into the logfmt format.
749 //! - [`reqwest-tracing`] provides a middleware to trace [`reqwest`] HTTP requests.
751 //! If you're the maintainer of a `tracing` ecosystem crate not listed above,
754 //! [`tracing-opentelemetry`]: https://crates.io/crates/tracing-opentelemetry
756 //! [`tracing-honeycomb`]: https://crates.io/crates/tracing-honeycomb
757 //! [`tracing-distributed`]: https://crates.io/crates/tracing-distributed
759 //! [`tracing-actix-web`]: https://crates.io/crates/tracing-actix-web
760 //! [`tracing-actix`]: https://crates.io/crates/tracing-actix
761 //! [`tracing-gelf`]: https://crates.io/crates/tracing-gelf
762 //! [`tracing-coz`]: https://crates.io/crates/tracing-coz
764 //! [`tracing-bunyan-formatter`]: https://crates.io/crates/tracing-bunyan-formatter
766 //! [`tracing-wasm`]: https://docs.rs/tracing-wasm
767 //! [`tracing-web`]: https://docs.rs/tracing-web
769 //! [`tide-tracing`]: https://crates.io/crates/tide-tracing
772 //! [`tracing-unwrap`]: https://docs.rs/tracing-unwrap
774 //! [`diesel-tracing`]: https://crates.io/crates/diesel-tracing
775 //! [`tracing-tracy`]: https://crates.io/crates/tracing-tracy
777 //! [`tracing-elastic-apm`]: https://crates.io/crates/tracing-elastic-apm
779 //! [`tracing-etw`]: https://github.com/microsoft/tracing-etw
780 //! [ETW]: https://docs.microsoft.com/en-us/windows/win32/etw/about-event-tracing
781 //! [`tracing-fluent-assertions`]: https://crates.io/crates/tracing-fluent-assertions
782 //! [`sentry-tracing`]: https://crates.io/crates/sentry-tracing
784 //! [`tracing-forest`]: https://crates.io/crates/tracing-forest
785 //! [`tracing-loki`]: https://crates.io/crates/tracing-loki
787 //! [`tracing-logfmt`]: https://crates.io/crates/tracing-logfmt
788 //! [`reqwest-tracing`]: https://crates.io/crates/reqwest-tracing
794 //! than <code>tracing</code> and <code>tracing-core</code>.
803 //! as trace events, if a default `tracing` subscriber has not been set. This
804 //! is intended for use in libraries whose users may be using either `tracing`
806 //! * `log-always`: Emit `log` records from all `tracing` spans and events, even
807 //! if a `tracing` subscriber has been set. This should be set only by
809 //! adapter is used to convert `log` records into `tracing` events, this will
820 //! tracing = { version = "0.1.37", default-features = false }
824 //! <strong>Note</strong>: <code>tracing</code>'s <code>no_std</code> support
861 //! Tracing is built against the latest stable release. The minimum supported
862 //! version is 1.49. The current Tracing version is not guaranteed to build on
865 //! Tracing follows the same compiler support policies as the rest of the Tokio
890 //! [`tokio-rs/tracing`]: https://github.com/tokio-rs/tracing
891 //! [`tracing-futures`]: https://crates.io/crates/tracing-futures
892 //! [`tracing-subscriber`]: https://crates.io/crates/tracing-subscriber
893 //! [`tracing-log`]: https://crates.io/crates/tracing-log
894 //! [`tracing-timing`]: https://crates.io/crates/tracing-timing
895 //! [`tracing-appender`]: https://crates.io/crates/tracing-appender
897 //! [`FmtSubscriber`]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Subs…
899 //! [instrument]: https://docs.rs/tracing-attributes/latest/tracing_attributes/attr.instrument.html
903 #![doc(html_root_url = "https://docs.rs/tracing/0.1.37")]
905 … html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
906 issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
983 /// a *private* API of `tracing`. It is exposed publicly because it is used
984 /// by the `tracing` macros, but it is not part of the stable versioned API.
991 /// a *private* API of `tracing`. It is exposed publicly because it is used
992 /// by the `tracing` macros, but it is not part of the stable versioned API.
1001 /// a *private* API of `tracing`. It is exposed publicly because it is used
1002 /// by the `tracing` macros, but it is not part of the stable versioned API.
1013 /// a *private* API of `tracing`. It is exposed publicly because it is used
1014 /// by the `tracing` macros, but it is not part of the stable versioned API.
1025 /// a *private* API of `tracing`. It is exposed publicly because it is used
1026 /// by the `tracing` macros, but it is not part of the stable versioned API.