| <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Core primitives for `tracing`."><meta name="keywords" content="rust, rustlang, rust-lang, tracing_core"><title>tracing_core - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../tracing_core/index.html"><div class="logo-container"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../tracing_core/index.html"><div class="logo-container"> |
| <img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></div></a><h2 class="location"><a href="#">Crate tracing_core</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.1.31</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">tracing_core</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/tracing_core/lib.rs.html#1-293">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Core primitives for <code>tracing</code>.</p> |
| <p><a href="https://crates.io/crates/tracing"><code>tracing</code></a> is a framework for instrumenting Rust programs to collect |
| structured, event-based diagnostic information. This crate defines the core |
| primitives of <code>tracing</code>.</p> |
| <p>This crate provides:</p> |
| <ul> |
| <li> |
| <p><a href="span/struct.Id.html"><code>span::Id</code></a> identifies a span within the execution of a program.</p> |
| </li> |
| <li> |
| <p><a href="struct.Event.html"><code>Event</code></a> represents a single event within a trace.</p> |
| </li> |
| <li> |
| <p><a href="trait.Subscriber.html"><code>Subscriber</code></a>, the trait implemented to collect trace data.</p> |
| </li> |
| <li> |
| <p><a href="struct.Metadata.html"><code>Metadata</code></a> and <a href="trait.Callsite.html"><code>Callsite</code></a> provide information describing spans and |
| <code>Event</code>s.</p> |
| </li> |
| <li> |
| <p><a href="struct.Field.html"><code>Field</code></a>, <a href="field/struct.FieldSet.html"><code>FieldSet</code></a>, <a href="field/trait.Value.html"><code>Value</code></a>, and <a href="field/struct.ValueSet.html"><code>ValueSet</code></a> represent the |
| structured data attached to a span.</p> |
| </li> |
| <li> |
| <p><a href="struct.Dispatch.html"><code>Dispatch</code></a> allows spans and events to be dispatched to <code>Subscriber</code>s.</p> |
| </li> |
| </ul> |
| <p>In addition, it defines the global callsite registry and per-thread current |
| dispatcher which other components of the tracing system rely on.</p> |
| <p><em>Compiler support: <a href="#supported-rust-versions">requires <code>rustc</code> 1.56+</a></em></p> |
| <h3 id="usage"><a href="#usage">Usage</a></h3> |
| <p>Application authors will typically not use this crate directly. Instead, |
| they will use the <a href="https://crates.io/crates/tracing"><code>tracing</code></a> crate, which provides a much more |
| fully-featured API. However, this crate’s API will change very infrequently, |
| so it may be used when dependencies must be very stable.</p> |
| <p><code>Subscriber</code> implementations may depend on <code>tracing-core</code> rather than |
| <code>tracing</code>, as the additional APIs provided by <code>tracing</code> are primarily useful |
| for instrumenting libraries and applications, and are generally not |
| necessary for <code>Subscriber</code> implementations.</p> |
| <p>The <a href="https://github.com/tokio-rs/tracing"><code>tokio-rs/tracing</code></a> repository contains less stable crates designed to |
| be used with the <code>tracing</code> ecosystem. It includes a collection of |
| <code>Subscriber</code> implementations, as well as utility and adapter crates.</p> |
| <h3 id="crate-feature-flags"><a href="#crate-feature-flags">Crate Feature Flags</a></h3> |
| <p>The following crate <a href="https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section">feature flags</a> are available:</p> |
| <ul> |
| <li> |
| <p><code>std</code>: Depend on the Rust standard library (enabled by default).</p> |
| <p><code>no_std</code> users may disable this feature with <code>default-features = false</code>:</p> |
| <div class="example-wrap"><pre class="language-toml"><code>[dependencies] |
| tracing-core = { version = "0.1.22", default-features = false }</code></pre></div> |
| <p><strong>Note</strong>:<code>tracing-core</code>’s <code>no_std</code> support requires <code>liballoc</code>.</p> |
| </li> |
| </ul> |
| <h4 id="unstable-features"><a href="#unstable-features">Unstable Features</a></h4> |
| <p>These feature flags enable <strong>unstable</strong> features. The public API may break in 0.1.x |
| releases. To enable these features, the <code>--cfg tracing_unstable</code> must be passed to |
| <code>rustc</code> when compiling.</p> |
| <p>The following unstable feature flags are currently available:</p> |
| <ul> |
| <li><code>valuable</code>: Enables support for recording <a href="field/index.html">field values</a> using the |
| <a href="https://crates.io/crates/valuable"><code>valuable</code></a> crate.</li> |
| </ul> |
| <h5 id="enabling-unstable-features"><a href="#enabling-unstable-features">Enabling Unstable Features</a></h5> |
| <p>The easiest way to set the <code>tracing_unstable</code> cfg is to use the <code>RUSTFLAGS</code> |
| env variable when running <code>cargo</code> commands:</p> |
| <div class="example-wrap"><pre class="language-shell"><code>RUSTFLAGS="--cfg tracing_unstable" cargo build</code></pre></div> |
| <p>Alternatively, the following can be added to the <code>.cargo/config</code> file in a |
| project to automatically enable the cfg flag for that project:</p> |
| <div class="example-wrap"><pre class="language-toml"><code>[build] |
| rustflags = ["--cfg", "tracing_unstable"]</code></pre></div><h3 id="supported-rust-versions"><a href="#supported-rust-versions">Supported Rust Versions</a></h3> |
| <p>Tracing is built against the latest stable release. The minimum supported |
| version is 1.56. The current Tracing version is not guaranteed to build on |
| Rust versions earlier than the minimum supported version.</p> |
| <p>Tracing follows the same compiler support policies as the rest of the Tokio |
| project. The current stable Rust compiler and the three most recent minor |
| versions before it will always be supported. For example, if the current |
| stable compiler version is 1.69, the minimum supported version will not be |
| increased past 1.66, three minor versions prior. Increasing the minimum |
| supported compiler version is not considered a semver breaking change as |
| long as doing so complies with this policy.</p> |
| </div></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2><div class="item-table"><div class="item-row"><div class="item-left import-item" id="reexport.Kind"><code>pub use self::metadata::<a class="struct" href="metadata/struct.Kind.html" title="struct tracing_core::metadata::Kind">Kind</a>;</code></div></div><div class="item-row"><div class="item-left import-item" id="reexport.Interest"><code>pub use self::subscriber::<a class="struct" href="subscriber/struct.Interest.html" title="struct tracing_core::subscriber::Interest">Interest</a>;</code></div></div></div><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="callsite/index.html" title="tracing_core::callsite mod">callsite</a></div><div class="item-right docblock-short">Callsites represent the source locations from which spans or events |
| originate.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="dispatcher/index.html" title="tracing_core::dispatcher mod">dispatcher</a></div><div class="item-right docblock-short">Dispatches trace events to <a href="trait.Subscriber.html" title="Subscriber"><code>Subscriber</code></a>s.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="event/index.html" title="tracing_core::event mod">event</a></div><div class="item-right docblock-short">Events represent single points in time during the execution of a program.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="field/index.html" title="tracing_core::field mod">field</a></div><div class="item-right docblock-short"><code>Span</code> and <code>Event</code> key-value data.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="metadata/index.html" title="tracing_core::metadata mod">metadata</a></div><div class="item-right docblock-short">Metadata describing trace data.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="span/index.html" title="tracing_core::span mod">span</a></div><div class="item-right docblock-short">Spans represent periods of time in the execution of a program.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="subscriber/index.html" title="tracing_core::subscriber mod">subscriber</a></div><div class="item-right docblock-short">Collectors collect and record trace data.</div></div></div><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.identify_callsite.html" title="tracing_core::identify_callsite macro">identify_callsite</a></div><div class="item-right docblock-short">Statically constructs an <a href="callsite/struct.Identifier.html"><code>Identifier</code></a> for the provided <a href="trait.Callsite.html"><code>Callsite</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.metadata.html" title="tracing_core::metadata macro">metadata</a></div><div class="item-right docblock-short">Statically constructs new span <a href="struct.Metadata.html">metadata</a>.</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Dispatch.html" title="tracing_core::Dispatch struct">Dispatch</a></div><div class="item-right docblock-short"><code>Dispatch</code> trace data to a <a href="trait.Subscriber.html" title="Subscriber"><code>Subscriber</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Event.html" title="tracing_core::Event struct">Event</a></div><div class="item-right docblock-short"><code>Event</code>s represent single points in time where something occurred during the |
| execution of a program.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Field.html" title="tracing_core::Field struct">Field</a></div><div class="item-right docblock-short">An opaque key allowing <em>O</em>(1) access to a field in a <code>Span</code>’s key-value |
| data.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Level.html" title="tracing_core::Level struct">Level</a></div><div class="item-right docblock-short">Describes the level of verbosity of a span or event.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.LevelFilter.html" title="tracing_core::LevelFilter struct">LevelFilter</a></div><div class="item-right docblock-short">A filter comparable to a verbosity <a href="struct.Level.html" title="Level"><code>Level</code></a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Metadata.html" title="tracing_core::Metadata struct">Metadata</a></div><div class="item-right docblock-short">Metadata describing a <a href="span/index.html">span</a> or <a href="event/index.html">event</a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Once.html" title="tracing_core::Once struct">Once</a></div><div class="item-right docblock-short">A synchronization primitive which can be used to run a one-time global |
| initialization. Useful for one-time initialization for FFI or related |
| functionality. This type can only be constructed with <a href="struct.Once.html#method.new" title="Once::new()"><code>Once::new()</code></a>.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Callsite.html" title="tracing_core::Callsite trait">Callsite</a></div><div class="item-right docblock-short">Trait implemented by callsites.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Subscriber.html" title="tracing_core::Subscriber trait">Subscriber</a></div><div class="item-right docblock-short">Trait representing the functions required to collect trace data.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="tracing_core" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html> |