Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,324 @@
<!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="Instruments a function to create and enter a `tracing` span every time the function is called."><title>instrument in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc attr"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">instrument</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">instrument</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#overriding-span-attributes" title="Overriding Span Attributes">Overriding Span Attributes</a></li><li><a href="#skipping-fields" title="Skipping Fields">Skipping Fields</a><ul><li><a href="#examples" title="Examples">Examples</a></li></ul></li><li><a href="#adding-fields" title="Adding Fields">Adding Fields</a><ul><li><a href="#examples-1" title="Examples">Examples</a></li></ul></li><li><a href="#examples-2" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Attribute Macro <span class="attr">instrument</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing_attributes/lib.rs.html#576-579">Source</a> </span></div><pre class="rust item-decl"><code>#[instrument]</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Instruments a function to create and enter a <code>tracing</code> <a href="https://docs.rs/tracing/latest/tracing/span/index.html">span</a> every time
the function is called.</p>
<p>Unless overridden, a span with the <a href="https://docs.rs/tracing/latest/tracing/struct.Level.html#associatedconstant.INFO"><code>INFO</code></a> <a href="https://docs.rs/tracing/latest/tracing/struct.Level.html">level</a> will be generated.
The generated spans name will be the name of the function.
By default, all arguments to the function are included as fields on the
span. Arguments that are <code>tracing</code> <a href="https://docs.rs/tracing/latest/tracing/field/trait.Value.html#foreign-impls">primitive types</a> implementing the
<a href="https://docs.rs/tracing/latest/tracing/field/trait.Value.html"><code>Value</code> trait</a> will be recorded as fields of that type. Types which do
not implement <code>Value</code> will be recorded using <a href="std::fmt::Debug"><code>fmt::Debug</code></a>.</p>
<h2 id="overriding-span-attributes"><a class="doc-anchor" href="#overriding-span-attributes">§</a>Overriding Span Attributes</h2>
<p>To change the <a href="https://docs.rs/tracing/latest/tracing/struct.Metadata.html#method.name">name</a> of the generated span, add a <code>name</code> argument to the
<code>#[instrument]</code> macro, followed by an equals sign and a string literal. For
example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="comment">// The generated span's name will be "my_span" rather than "my_function".
</span><span class="attr">#[instrument(name = <span class="string">"my_span"</span>)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ... do something incredibly interesting and important ...
</span>}</code></pre></div>
<p>To override the <a href="https://docs.rs/tracing/latest/tracing/struct.Metadata.html#method.target">target</a> of the generated span, add a <code>target</code> argument to
the <code>#[instrument]</code> macro, followed by an equals sign and a string literal
for the new target. The <a href="https://docs.rs/tracing/latest/tracing/struct.Metadata.html#method.module_path">module path</a> is still recorded separately. For
example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">pub mod </span>my_module {
<span class="comment">// The generated span's target will be "my_crate::some_special_target",
// rather than "my_crate::my_module".
</span><span class="attr">#[instrument(target = <span class="string">"my_crate::some_special_target"</span>)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ... all kinds of neat code in here ...
</span>}
}</code></pre></div>
<p>Finally, to override the <a href="https://docs.rs/tracing/latest/tracing/struct.Level.html">level</a> of the generated span, add a <code>level</code>
argument, followed by an equals sign and a string literal with the name of
the desired level. Level names are not case sensitive. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// The span's level will be TRACE rather than INFO.
</span><span class="attr">#[instrument(level = <span class="string">"trace"</span>)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ... I have written a truly marvelous implementation of this function,
// which this example is too narrow to contain ...
</span>}</code></pre></div><h2 id="skipping-fields"><a class="doc-anchor" href="#skipping-fields">§</a>Skipping Fields</h2>
<p>To skip recording one or more arguments to a function or method, pass
the arguments name inside the <code>skip()</code> argument on the <code>#[instrument]</code>
macro. This can be used when an argument to an instrumented function does
not implement <a href="std::fmt::Debug"><code>fmt::Debug</code></a>, or to exclude an argument with a verbose or
costly <code>Debug</code> implementation. Note that:</p>
<ul>
<li>multiple argument names can be passed to <code>skip</code>.</li>
<li>arguments passed to <code>skip</code> do <em>not</em> need to implement <code>fmt::Debug</code>.</li>
</ul>
<p>You can also use <code>skip_all</code> to skip all arguments.</p>
<h3 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// This type doesn't implement `fmt::Debug`!
</span><span class="kw">struct </span>NonDebug;
<span class="comment">// `arg` will be recorded, while `non_debug` will not.
</span><span class="attr">#[instrument(skip(non_debug))]
</span><span class="kw">fn </span>my_function(arg: usize, non_debug: NonDebug) {
<span class="comment">// ...
</span>}
<span class="comment">// These arguments are huge
</span><span class="attr">#[instrument(skip_all)]
</span><span class="kw">fn </span>my_big_data_function(large: Vec&lt;u8&gt;, also_large: HashMap&lt;String, String&gt;) {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Skipping the <code>self</code> parameter:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[derive(Debug)]
</span><span class="kw">struct </span>MyType {
data: Vec&lt;u8&gt;, <span class="comment">// Suppose this buffer is often quite long...
</span>}
<span class="kw">impl </span>MyType {
<span class="comment">// Suppose we don't want to print an entire kilobyte of `data`
// every time this is called...
</span><span class="attr">#[instrument(skip(<span class="self">self</span>))]
</span><span class="kw">pub fn </span>my_method(<span class="kw-2">&amp;mut </span><span class="self">self</span>, an_interesting_argument: usize) {
<span class="comment">// ... do something (hopefully, using all that `data`!)
</span>}
}</code></pre></div><h2 id="adding-fields"><a class="doc-anchor" href="#adding-fields">§</a>Adding Fields</h2>
<p>Additional fields (key-value pairs with arbitrary data) can be passed
to the generated span through the <code>fields</code> argument on the
<code>#[instrument]</code> macro. Arbitrary expressions are accepted as value
for each field. The name of the field must be a single valid Rust
identifier, or a constant expression that evaluates to one, enclosed in curly
braces. Note that nested (dotted) field names are also supported. Any
Rust expression can be used as a field value in this manner. These
expressions will be evaluated at the beginning of the functions body, so
arguments to the function may be used in these expressions. Field names may
also be specified <em>without</em> values. Doing so will result in an <a href="https://docs.rs/tracing/latest/tracing/field/struct.Empty.html">empty field</a>
whose value may be recorded later within the function body.</p>
<p>Note that defining a field with the same name as a (non-skipped)
argument will implicitly skip the argument, unless the field is provided
via a constant expression (e.g. {EXPR} or {const_fn()}) as deduplicating
would incur a runtime cost. In this case, the
field must be explicitly skipped.</p>
<h3 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h3>
<p>Adding a new field based on the value of an argument:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="comment">// This will record a field named "i" with the value of `i` *and* a field
// named "next" with the value of `i` + 1.
</span><span class="attr">#[instrument(fields(next = i + <span class="number">1</span>))]
</span><span class="kw">pub fn </span>my_function(i: usize) {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Recording specific properties of a struct as their own fields:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="comment">// This will record the request's URI and HTTP method as their own separate
// fields.
</span><span class="attr">#[instrument(fields(http.uri = req.uri(), http.method = req.method()))]
</span><span class="kw">pub fn </span>handle_request&lt;B&gt;(req: http::Request&lt;B&gt;) -&gt; http::Response&lt;B&gt; {
<span class="comment">// ... handle the request ...
</span>}</code></pre></div>
<p>This can be used in conjunction with <code>skip</code> or <code>skip_all</code> to record only
some fields of a struct:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Remember the struct with the very large `data` field from the earlier
// example? Now it also has a `name`, which we might want to include in
// our span.
</span><span class="attr">#[derive(Debug)]
</span><span class="kw">struct </span>MyType {
name: <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str,
data: Vec&lt;u8&gt;,
}
<span class="kw">impl </span>MyType {
<span class="comment">// This will skip the `data` field, but will include `self.name`,
// formatted using `fmt::Display`.
</span><span class="attr">#[instrument(skip(<span class="self">self</span>), fields(<span class="self">self</span>.name = %<span class="self">self</span>.name))]
</span><span class="kw">pub fn </span>my_method(<span class="kw-2">&amp;mut </span><span class="self">self</span>, an_interesting_argument: usize) {
<span class="comment">// ... do something (hopefully, using all that `data`!)
</span>}
}</code></pre></div>
<p>Adding an empty field to be recorded later:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="comment">// This function does a very interesting and important mathematical calculation.
// Suppose we want to record both the inputs to the calculation *and* its result...
</span><span class="attr">#[instrument(fields(result))]
</span><span class="kw">pub fn </span>do_calculation(input_1: usize, input_2: usize) -&gt; usize {
<span class="comment">// Rerform the calculation.
</span><span class="kw">let </span>result = input_1 + input_2;
<span class="comment">// Record the result as part of the current span.
</span>tracing::Span::current().record(<span class="string">"result"</span>, <span class="kw-2">&amp;</span>result);
<span class="comment">// Now, the result will also be included on this event!
</span><span class="macro">tracing::info!</span>(<span class="string">"calculation complete!"</span>);
<span class="comment">// ... etc ...
</span>}</code></pre></div><h2 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h2>
<p>Instrumenting a function:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument]
</span><span class="kw">pub fn </span>my_function(my_arg: usize) {
<span class="comment">// This event will be recorded inside a span named `my_function` with the
// field `my_arg`.
</span><span class="macro">tracing::info!</span>(<span class="string">"inside my_function!"</span>);
<span class="comment">// ...
</span>}</code></pre></div>
<p>Setting the level for the generated span:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(level = Level::DEBUG)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Levels can be specified either with <a href="https://docs.rs/tracing/latest/tracing/struct.Level.html"><code>Level</code></a> constants, literal strings
(e.g., <code>"debug"</code>, <code>"info"</code>) or numerically (1—5, corresponding to <a href="https://docs.rs/tracing/latest/tracing/struct.Level.html#associatedconstant.TRACE"><code>Level::TRACE</code></a><a href="https://docs.rs/tracing/latest/tracing/struct.Level.html#associatedconstant.ERROR"><code>Level::ERROR</code></a>).</p>
<p>Overriding the generated spans name:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(name = <span class="string">"my_name"</span>)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Overriding the generated spans target:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(target = <span class="string">"my_target"</span>)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Overriding the generated spans parent:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(parent = <span class="prelude-val">None</span>)]
</span><span class="kw">pub fn </span>my_function() {
<span class="comment">// ...
</span>}</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// A struct which owns a span handle.
</span><span class="kw">struct </span>MyStruct
{
span: tracing::Span
}
<span class="kw">impl </span>MyStruct
{
<span class="comment">// Use the struct's `span` field as the parent span
</span><span class="attr">#[instrument(parent = <span class="kw-2">&amp;</span><span class="self">self</span>.span, skip(<span class="self">self</span>))]
</span><span class="kw">fn </span>my_method(<span class="kw-2">&amp;</span><span class="self">self</span>) {}
}</code></pre></div>
<p>Specifying <a href="https://docs.rs/tracing/latest/tracing/struct.Span.html#method.follows_from"><code>follows_from</code></a> relationships:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(follows_from = causes)]
</span><span class="kw">pub fn </span>my_function(causes: <span class="kw-2">&amp;</span>[tracing::Id]) {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Any expression of type <code>impl IntoIterator&lt;Item = impl Into&lt;Option&lt;Id&gt;&gt;&gt;</code>
may be provided to <code>follows_from</code>; e.g.:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(follows_from = [cause]</span>)]
<span class="kw">pub fn </span>my_function(cause: <span class="kw-2">&amp;</span>tracing::span::EnteredSpan) {
<span class="comment">// ...
</span>}</code></pre></div>
<p>To skip recording an argument, pass the arguments name to the <code>skip</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>NonDebug;
<span class="attr">#[instrument(skip(non_debug))]
</span><span class="kw">fn </span>my_function(arg: usize, non_debug: NonDebug) {
<span class="comment">// ...
</span>}</code></pre></div>
<p>To add additional context to the span, pass key-value pairs to <code>fields</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[derive(Debug)]
</span><span class="kw">struct </span>Argument;
<span class="kw">impl </span>Argument {
<span class="kw">fn </span>bar(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str {
<span class="string">"bar"
</span>}
}
<span class="kw">const </span>FOOBAR: <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str = <span class="string">"foo.bar"</span>;
<span class="attr">#[instrument(fields(foo=<span class="string">"bar"</span>, id=<span class="number">1</span>, show=<span class="bool-val">true</span>, {FOOBAR}=%arg.bar()))]
</span><span class="kw">fn </span>my_function(arg: Argument) {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Adding the <code>ret</code> argument to <code>#[instrument]</code> will emit an event with the functions
return value when the function returns:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(ret)]
</span><span class="kw">fn </span>my_function() -&gt; i32 {
<span class="number">42
</span>}</code></pre></div>
<p>The return value event will have the same level as the span generated by <code>#[instrument]</code>.
By default, this will be <a href="https://docs.rs/tracing/latest/tracing/struct.Level.html#associatedconstant.INFO"><code>INFO</code></a>, but if the level is overridden, the event will be at the same
level.</p>
<p>Its also possible to override the level for the <code>ret</code> event independently:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(ret(level = Level::WARN))]
</span><span class="kw">fn </span>my_function() -&gt; i32 {
<span class="number">42
</span>}</code></pre></div>
<p><strong>Note</strong>: if the function returns a <code>Result&lt;T, E&gt;</code>, <code>ret</code> will record returned values if and
only if the function returns [<code>Result::Ok</code>].</p>
<p>By default, returned values will be recorded using their [<code>std::fmt::Debug</code>] implementations.
If a returned value implements [<code>std::fmt::Display</code>], it can be recorded using its <code>Display</code>
implementation instead, by writing <code>ret(Display)</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(ret(Display))]
</span><span class="kw">fn </span>my_function() -&gt; i32 {
<span class="number">42
</span>}</code></pre></div>
<p>If the function returns a <code>Result&lt;T, E&gt;</code> and <code>E</code> implements <code>std::fmt::Display</code>, adding
<code>err</code> or <code>err(Display)</code> will emit error events when the function returns <code>Err</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(err)]
</span><span class="kw">fn </span>my_function(arg: usize) -&gt; <span class="prelude-ty">Result</span>&lt;(), std::io::Error&gt; {
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<p>The level of the error value event defaults to <code>ERROR</code>.</p>
<p>Similarly, overriding the level of the <code>err</code> event :</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(err(level = Level::INFO))]
</span><span class="kw">fn </span>my_function(arg: usize) -&gt; <span class="prelude-ty">Result</span>&lt;(), std::io::Error&gt; {
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<p>By default, error values will be recorded using their <code>std::fmt::Display</code> implementations.
If an error implements <code>std::fmt::Debug</code>, it can be recorded using its <code>Debug</code> implementation
instead by writing <code>err(Debug)</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(err(Debug))]
</span><span class="kw">fn </span>my_function(arg: usize) -&gt; <span class="prelude-ty">Result</span>&lt;(), std::io::Error&gt; {
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<p>If a <code>target</code> is specified, both the <code>ret</code> and <code>err</code> arguments will emit outputs to
the declared target (or the default channel if <code>target</code> is not specified).</p>
<p>The <code>ret</code> and <code>err</code> arguments can be combined in order to record an event if a
function returns [<code>Result::Ok</code>] or [<code>Result::Err</code>]:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument(err, ret)]
</span><span class="kw">fn </span>my_function(arg: usize) -&gt; <span class="prelude-ty">Result</span>&lt;(), std::io::Error&gt; {
<span class="prelude-val">Ok</span>(())
}</code></pre></div>
<p><code>async fn</code>s may also be instrumented:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument]
</span><span class="kw">pub async fn </span>my_function() -&gt; <span class="prelude-ty">Result</span>&lt;(), ()&gt; {
<span class="comment">// ...
</span>}</code></pre></div>
<p>It also works with <a href="https://crates.io/crates/async-trait">async-trait</a>
(a crate that allows defining async functions in traits,
something not currently possible in Rust),
and hopefully most libraries that exhibit similar behaviors:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>async_trait::async_trait;
<span class="attr">#[async_trait]
</span><span class="kw">pub trait </span>Foo {
<span class="kw">async fn </span>foo(<span class="kw-2">&amp;</span><span class="self">self</span>, arg: usize);
}
<span class="attr">#[derive(Debug)]
</span><span class="kw">struct </span>FooImpl(usize);
<span class="attr">#[async_trait]
</span><span class="kw">impl </span>Foo <span class="kw">for </span>FooImpl {
<span class="attr">#[instrument(fields(value = <span class="self">self</span>.<span class="number">0</span>, tmp = std::any::type_name::&lt;<span class="self">Self</span>&gt;()))]
</span><span class="kw">async fn </span>foo(<span class="kw-2">&amp;</span><span class="self">self</span>, arg: usize) {}
}</code></pre></div>
<p><code>const fn</code> cannot be instrumented, and will result in a compilation failure:</p>
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile"></a><pre class="rust rust-example-rendered"><code><span class="attr">#[instrument]
</span><span class="kw">const fn </span>my_const_function() {}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,6 @@
<!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="Executes a closure with a reference to this threads current dispatcher."><title>get_default in tracing::dispatcher - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">get_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>dispatcher</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">dispatcher</a></div><h1>Function <span class="fn">get_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/dispatcher.rs.html#379-381">Source</a> </span></div><pre class="rust item-decl"><code>pub fn get_default&lt;T, F&gt;(f: F) -&gt; T<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;<a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>) -&gt; T,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Executes a closure with a reference to this threads current <a href="../struct.Dispatch.html" title="struct tracing::Dispatch">dispatcher</a>.</p>
<p>Note that calls to <code>get_default</code> should not be nested; if this function is
called while inside of another <code>get_default</code>, that closure will be provided
with <code>Dispatch::none</code> rather than the previously set dispatcher.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,8 @@
<!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="Sets the dispatch as the default dispatch for the duration of the lifetime of the returned DefaultGuard"><title>set_default in tracing::dispatcher - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">set_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>dispatcher</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">dispatcher</a></div><h1>Function <span class="fn">set_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/dispatcher.rs.html#276">Source</a> </span></div><pre class="rust item-decl"><code>pub fn set_default(dispatcher: &amp;<a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>) -&gt; <a class="struct" href="struct.DefaultGuard.html" title="struct tracing::dispatcher::DefaultGuard">DefaultGuard</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sets the dispatch as the default dispatch for the duration of the lifetime
of the returned DefaultGuard</p>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: This function required the Rust standard library.
<code>no_std</code> users should use <a href="fn.set_global_default.html">
<code>set_global_default</code></a> instead.
</pre>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,13 @@
<!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="Sets this dispatch as the global default for the duration of the entire program. Will be used as a fallback if no thread-local dispatch has been set in a thread (using `with_default`.)"><title>set_global_default in tracing::dispatcher - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">set_global_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>dispatcher</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">dispatcher</a></div><h1>Function <span class="fn">set_<wbr>global_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/dispatcher.rs.html#299">Source</a> </span></div><pre class="rust item-decl"><code>pub fn set_global_default(
dispatcher: <a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="struct.SetGlobalDefaultError.html" title="struct tracing::dispatcher::SetGlobalDefaultError">SetGlobalDefaultError</a>&gt;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sets this dispatch as the global default for the duration of the entire program.
Will be used as a fallback if no thread-local dispatch has been set in a thread
(using <code>with_default</code>.)</p>
<p>Can only be set once; subsequent attempts to set the global default will fail.
Returns <code>Err</code> if the global default has already been set.</p>
<div class="example-wrap" style="display:inline-block"><pre class="compile_fail" style="white-space:normal;font:inherit;">
<strong>Warning</strong>: In general, libraries should <em>not</em> call
<code>set_global_default()</code>! Doing so will cause conflicts when
executables that depend on the library try to set the default later.
</pre></div>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,9 @@
<!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="Sets this dispatch as the default for the duration of a closure."><title>with_default in tracing::dispatcher - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">with_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>dispatcher</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">dispatcher</a></div><h1>Function <span class="fn">with_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/dispatcher.rs.html#254">Source</a> </span></div><pre class="rust item-decl"><code>pub fn with_default&lt;T&gt;(dispatcher: &amp;<a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>, f: impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; T) -&gt; T</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sets this dispatch as the default for the duration of a closure.</p>
<p>The default dispatcher is used when creating a new <a href="../../tracing_core/span/index.html" title="mod tracing_core::span">span</a> or
<a href="../struct.Event.html" title="struct tracing::Event"><code>Event</code></a>.</p>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: This function required the Rust standard library.
<code>no_std</code> users should use <a href="fn.set_global_default.html">
<code>set_global_default</code></a> instead.
</pre>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,65 @@
<!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="Dispatches trace events to `Subscriber`s."><title>tracing::dispatcher - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module dispatcher</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module dispatcher</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#using-the-trace-dispatcher" title="Using the Trace Dispatcher">Using the Trace Dispatcher</a><ul><li><a href="#setting-the-default-subscriber" title="Setting the Default Subscriber">Setting the Default Subscriber</a></li><li><a href="#accessing-the-default-subscriber" title="Accessing the Default Subscriber">Accessing the Default Subscriber</a></li></ul></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>dispatcher</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/dispatcher.rs.html#1-145">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Dispatches trace events to <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>s.</p>
<p>The <em>dispatcher</em> is the component of the tracing system which is responsible
for forwarding trace data from the instrumentation points that generate it
to the subscriber that collects it.</p>
<h2 id="using-the-trace-dispatcher"><a class="doc-anchor" href="#using-the-trace-dispatcher">§</a>Using the Trace Dispatcher</h2>
<p>Every thread in a program using <code>tracing</code> has a <em>default subscriber</em>. When
events occur, or spans are created, they are dispatched to the threads
current subscriber.</p>
<h3 id="setting-the-default-subscriber"><a class="doc-anchor" href="#setting-the-default-subscriber">§</a>Setting the Default Subscriber</h3>
<p>By default, the current subscriber is an empty implementation that does
nothing. To use a subscriber implementation, it must be set as the default.
There are two methods for doing so: <a href="fn.with_default.html" title="fn tracing::dispatcher::with_default"><code>with_default</code></a> and
<a href="fn.set_global_default.html" title="fn tracing::dispatcher::set_global_default"><code>set_global_default</code></a>. <code>with_default</code> sets the default subscriber for the
duration of a scope, while <code>set_global_default</code> sets a default subscriber
for the entire process.</p>
<p>To use either of these functions, we must first wrap our subscriber in a
<a href="../struct.Dispatch.html" title="struct tracing::Dispatch"><code>Dispatch</code></a>, a cloneable, type-erased reference to a subscriber. For
example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>dispatcher::Dispatch;
<span class="kw">let </span>my_subscriber = FooSubscriber::new();
<span class="kw">let </span>my_dispatch = Dispatch::new(my_subscriber);</code></pre></div>
<p>Then, we can use <a href="fn.with_default.html" title="fn tracing::dispatcher::with_default"><code>with_default</code></a> to set our <code>Dispatch</code> as the default for
the duration of a block:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// no default subscriber
</span>dispatcher::with_default(<span class="kw-2">&amp;</span>my_dispatch, || {
<span class="comment">// my_subscriber is the default
</span>});
<span class="comment">// no default subscriber again</span></code></pre></div>
<p>Its important to note that <code>with_default</code> will not propagate the current
threads default subscriber to any threads spawned within the <code>with_default</code>
block. To propagate the default subscriber to new threads, either use
<code>with_default</code> from the new thread, or use <code>set_global_default</code>.</p>
<p>As an alternative to <code>with_default</code>, we can use <a href="fn.set_global_default.html" title="fn tracing::dispatcher::set_global_default"><code>set_global_default</code></a> to
set a <code>Dispatch</code> as the default for all threads, for the lifetime of the
program. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// no default subscriber
</span>dispatcher::set_global_default(my_dispatch)
<span class="comment">// `set_global_default` will return an error if the global default
// subscriber has already been set.
</span>.expect(<span class="string">"global default was already set!"</span>);
<span class="comment">// `my_subscriber` is now the default</span></code></pre></div><pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: The thread-local scoped dispatcher (<code>with_default</code>)
requires the Rust standard library. <code>no_std</code> users should
use <a href="fn.set_global_default.html"><code>set_global_default</code></a>
instead.
</pre>
<h3 id="accessing-the-default-subscriber"><a class="doc-anchor" href="#accessing-the-default-subscriber">§</a>Accessing the Default Subscriber</h3>
<p>A threads current default subscriber can be accessed using the
<a href="fn.get_default.html" title="fn tracing::dispatcher::get_default"><code>get_default</code></a> function, which executes a closure with a reference to the
currently default <code>Dispatch</code>. This is used primarily by <code>tracing</code>
instrumentation.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.DefaultGuard.html" title="struct tracing::dispatcher::DefaultGuard">Default<wbr>Guard</a></dt><dd>A guard that resets the current default dispatcher to the prior
default dispatcher when dropped.</dd><dt><a class="struct" href="struct.Dispatch.html" title="struct tracing::dispatcher::Dispatch">Dispatch</a></dt><dd><code>Dispatch</code> trace data to a <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</dd><dt><a class="struct" href="struct.SetGlobalDefaultError.html" title="struct tracing::dispatcher::SetGlobalDefaultError">SetGlobal<wbr>Default<wbr>Error</a></dt><dd>Returned if setting the global dispatcher fails.</dd><dt><a class="struct" href="struct.WeakDispatch.html" title="struct tracing::dispatcher::WeakDispatch">Weak<wbr>Dispatch</a></dt><dd><code>WeakDispatch</code> is a version of <a href="../struct.Dispatch.html" title="struct tracing::Dispatch"><code>Dispatch</code></a> that holds a non-owning reference
to a <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.get_default.html" title="fn tracing::dispatcher::get_default">get_<wbr>default</a></dt><dd>Executes a closure with a reference to this threads current <a href="../struct.Dispatch.html" title="struct tracing::Dispatch">dispatcher</a>.</dd><dt><a class="fn" href="fn.set_default.html" title="fn tracing::dispatcher::set_default">set_<wbr>default</a></dt><dd>Sets the dispatch as the default dispatch for the duration of the lifetime
of the returned DefaultGuard</dd><dt><a class="fn" href="fn.set_global_default.html" title="fn tracing::dispatcher::set_global_default">set_<wbr>global_<wbr>default</a></dt><dd>Sets this dispatch as the global default for the duration of the entire program.
Will be used as a fallback if no thread-local dispatch has been set in a thread
(using <code>with_default</code>.)</dd><dt><a class="fn" href="fn.with_default.html" title="fn tracing::dispatcher::with_default">with_<wbr>default</a></dt><dd>Sets this dispatch as the default for the duration of a closure.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["get_default","set_default","set_global_default","with_default"],"struct":["DefaultGuard","Dispatch","SetGlobalDefaultError","WeakDispatch"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
<!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="Events represent single points in time during the execution of a program."><title>tracing::event - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module event</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module event</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>event</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/lib.rs.html#285">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Events represent single points in time during the execution of a program.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Event.html" title="struct tracing::event::Event">Event</a></dt><dd><code>Event</code>s represent single points in time where something occurred during the
execution of a program.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Event"]};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
<!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="Wraps a type implementing `fmt::Debug` as a `Value` that can be recorded using its `Debug` implementation."><title>debug in tracing::field - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">debug</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>field</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">field</a></div><h1>Function <span class="fn">debug</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/field.rs.html#377-379">Source</a> </span></div><pre class="rust item-decl"><code>pub fn debug&lt;T&gt;(t: T) -&gt; <a class="struct" href="struct.DebugValue.html" title="struct tracing::field::DebugValue">DebugValue</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Wraps a type implementing <code>fmt::Debug</code> as a <code>Value</code> that can be
recorded using its <code>Debug</code> implementation.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,4 @@
<!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="Wraps a type implementing `fmt::Display` as a `Value` that can be recorded using its `Display` implementation."><title>display in tracing::field - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">display</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>field</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">field</a></div><h1>Function <span class="fn">display</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/field.rs.html#368-370">Source</a> </span></div><pre class="rust item-decl"><code>pub fn display&lt;T&gt;(t: T) -&gt; <a class="struct" href="struct.DisplayValue.html" title="struct tracing::field::DisplayValue">DisplayValue</a>&lt;T&gt;<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Wraps a type implementing <code>fmt::Display</code> as a <code>Value</code> that can be
recorded using its <code>Display</code> implementation.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,85 @@
<!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="`Span` and `Event` key-value data."><title>tracing::field - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module field</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module field</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#values-and-subscribers" title="`Value`s and `Subscriber`s"><code>Value</code>s and <code>Subscriber</code>s</a></li><li><a href="#using-valuable" title="Using `valuable`">Using <code>valuable</code></a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>field</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/field.rs.html#1-170">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>Span</code> and <code>Event</code> key-value data.</p>
<p>Spans and events may be annotated with key-value data, referred to as <em>fields</em>.
These fields consist of a mapping from a key (corresponding to
a <code>&amp;str</code> but represented internally as an array index) to a <a href="../trait.Value.html" title="trait tracing::Value"><code>Value</code></a>.</p>
<h2 id="values-and-subscribers"><a class="doc-anchor" href="#values-and-subscribers">§</a><code>Value</code>s and <code>Subscriber</code>s</h2>
<p><code>Subscriber</code>s consume <code>Value</code>s as fields attached to <a href="../span/index.html" title="mod tracing::span">span</a>s or <a href="../struct.Event.html" title="struct tracing::Event"><code>Event</code></a>s.
The set of field keys on a given span or event is defined on its <a href="../struct.Metadata.html" title="struct tracing::Metadata"><code>Metadata</code></a>.
When a span is created, it provides <a href="../span/struct.Attributes.html" title="struct tracing::span::Attributes"><code>Attributes</code></a> to the <code>Subscriber</code>s
<a href="../trait.Subscriber.html#tymethod.new_span" title="method tracing::Subscriber::new_span"><code>new_span</code></a> method, containing any fields whose values were provided when
the span was created; and may call the <code>Subscriber</code>s <a href="../span/struct.Record.html" title="struct tracing::span::Record"><code>record</code></a> method
with additional <a href="../span/struct.Record.html" title="struct tracing::span::Record"><code>Record</code></a>s if values are added for more of its fields.
Similarly, the <a href="../struct.Event.html" title="struct tracing::Event"><code>Event</code></a> type passed to the subscribers <a href="../struct.Event.html" title="struct tracing::Event"><code>event</code></a> method
will contain any fields attached to each event.</p>
<p><code>tracing</code> represents values as either one of a set of Rust primitives
(<code>i64</code>, <code>u64</code>, <code>f64</code>, <code>bool</code>, and <code>&amp;str</code>) or using a <code>fmt::Display</code> or
<code>fmt::Debug</code> implementation. <code>Subscriber</code>s are provided these primitive
value types as <code>dyn Value</code> trait objects.</p>
<p>These trait objects can be formatted using <code>fmt::Debug</code>, but may also be
recorded as typed data by calling the <a href="../trait.Value.html#tymethod.record" title="method tracing::Value::record"><code>Value::record</code></a> method on these
trait objects with a <em>visitor</em> implementing the <a href="trait.Visit.html" title="trait tracing::field::Visit"><code>Visit</code></a> trait. This trait
represents the behavior used to record values of various types. For example,
an implementation of <code>Visit</code> might record integers by incrementing counters
for their field names rather than printing them.</p>
<h2 id="using-valuable"><a class="doc-anchor" href="#using-valuable">§</a>Using <code>valuable</code></h2>
<p><code>tracing</code>s <a href="../trait.Value.html" title="trait tracing::Value"><code>Value</code></a> trait is intentionally minimalist: it supports only a small
number of Rust primitives as typed values, and only permits recording
user-defined types with their <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug"><code>fmt::Debug</code></a> or <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug"><code>fmt::Display</code></a>
implementations. However, there are some cases where it may be useful to record
nested values (such as arrays, <code>Vec</code>s, or <code>HashMap</code>s containing values), or
user-defined <code>struct</code> and <code>enum</code> types without having to format them as
unstructured text.</p>
<p>To address <code>Value</code>s limitations, <code>tracing</code> offers experimental support for
the <a href="https://crates.io/crates/valuable"><code>valuable</code></a> crate, which provides object-safe inspection of structured
values. User-defined types can implement the <a href="https://docs.rs/valuable/latest/valuable/trait.Valuable.html"><code>valuable::Valuable</code></a> trait,
and be recorded as a <code>tracing</code> field by calling their <a href="https://docs.rs/valuable/latest/valuable/trait.Valuable.html#tymethod.as_value"><code>as_value</code></a> method.
If the <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> also supports the <code>valuable</code> crate, it can
then visit those types fields as structured values using <code>valuable</code>.</p>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: <code>valuable</code> support is an
<a href = "../index.html#unstable-features">unstable feature</a>. See
the documentation on unstable features for details on how to enable it.
</pre>
<p>For example:</p>
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested"></a><pre class="rust rust-example-rendered"><code><span class="comment">// Derive `Valuable` for our types:
</span><span class="kw">use </span>valuable::Valuable;
<span class="attr">#[derive(Clone, Debug, Valuable)]
</span><span class="kw">struct </span>User {
name: String,
age: u32,
address: Address,
}
<span class="attr">#[derive(Clone, Debug, Valuable)]
</span><span class="kw">struct </span>Address {
country: String,
city: String,
street: String,
}
<span class="kw">let </span>user = User {
name: <span class="string">"Arwen Undomiel"</span>.to_string(),
age: <span class="number">3000</span>,
address: Address {
country: <span class="string">"Middle Earth"</span>.to_string(),
city: <span class="string">"Rivendell"</span>.to_string(),
street: <span class="string">"leafy lane"</span>.to_string(),
},
};
<span class="comment">// Recording `user` as a `valuable::Value` will allow the `tracing` subscriber
// to traverse its fields as a nested, typed structure:
</span><span class="macro">tracing::info!</span>(current_user = user.as_value());</code></pre></div>
<p>Alternatively, the [<code>valuable()</code>] function may be used to convert a type
implementing <a href="https://crates.io/crates/valuable"><code>Valuable</code></a> into a <code>tracing</code> field value.</p>
<p>When the <code>valuable</code> feature is enabled, the <a href="trait.Visit.html" title="trait tracing::field::Visit"><code>Visit</code></a> trait will include an
optional <a href="Visit::record_value"><code>record_value</code></a> method. <code>Visit</code> implementations that wish to
record <code>valuable</code> values can implement this method with custom behavior.
If a visitor does not implement <code>record_value</code>, the <a href="https://docs.rs/valuable/latest/valuable/enum.Value.html"><code>valuable::Value</code></a> will
be forwarded to the visitors <a href="trait.Visit.html#tymethod.record_debug" title="method tracing::field::Visit::record_debug"><code>record_debug</code></a> method.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.DebugValue.html" title="struct tracing::field::DebugValue">Debug<wbr>Value</a></dt><dd>A <code>Value</code> which serializes as a string using <code>fmt::Debug</code>.</dd><dt><a class="struct" href="struct.DisplayValue.html" title="struct tracing::field::DisplayValue">Display<wbr>Value</a></dt><dd>A <code>Value</code> which serializes using <code>fmt::Display</code>.</dd><dt><a class="struct" href="struct.Empty.html" title="struct tracing::field::Empty">Empty</a></dt><dd>An empty field.</dd><dt><a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a></dt><dd>An opaque key allowing <em>O</em>(1) access to a field in a <code>Span</code>s key-value
data.</dd><dt><a class="struct" href="struct.FieldSet.html" title="struct tracing::field::FieldSet">Field<wbr>Set</a></dt><dd>Describes the fields present on a span.</dd><dt><a class="struct" href="struct.Iter.html" title="struct tracing::field::Iter">Iter</a></dt><dd>An iterator over a set of fields.</dd><dt><a class="struct" href="struct.ValueSet.html" title="struct tracing::field::ValueSet">Value<wbr>Set</a></dt><dd>A set of fields and values for a span.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.AsField.html" title="trait tracing::field::AsField">AsField</a></dt><dd>Trait implemented to allow a type to be used as a field key.</dd><dt><a class="trait" href="trait.Value.html" title="trait tracing::field::Value">Value</a></dt><dd>A field value of an erased type.</dd><dt><a class="trait" href="trait.Visit.html" title="trait tracing::field::Visit">Visit</a></dt><dd>Visits typed values.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.debug.html" title="fn tracing::field::debug">debug</a></dt><dd>Wraps a type implementing <code>fmt::Debug</code> as a <code>Value</code> that can be
recorded using its <code>Debug</code> implementation.</dd><dt><a class="fn" href="fn.display.html" title="fn tracing::field::display">display</a></dt><dd>Wraps a type implementing <code>fmt::Display</code> as a <code>Value</code> that can be
recorded using its <code>Display</code> implementation.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["debug","display"],"struct":["DebugValue","DisplayValue","Empty","Field","FieldSet","Iter","ValueSet"],"trait":["AsField","Value","Visit"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
<!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="Trait implemented to allow a type to be used as a field key."><title>AsField in tracing::field - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">AsField</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">AsField</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.as_field" title="as_field">as_field</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-AsField-for-str" title="str">str</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>field</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">field</a></div><h1>Trait <span class="trait">AsField</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/field.rs.html#129-135">Source</a> </span></div><pre class="rust item-decl"><code>pub trait AsField: Sealed {
// Required method
fn <a href="#tymethod.as_field" class="fn">as_field</a>(&amp;self, metadata: &amp;<a class="struct" href="../struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>&gt;;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait implemented to allow a type to be used as a field key.</p>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: Although this is implemented for both the
<a href="./struct.Field.html"><code>Field</code></a> type <em>and</em> any
type that can be borrowed as an <code>&str</code>, only <code>Field</code>
allows <em>O</em>(1) access.
Indexing a field with a string results in an iterative search that performs
string comparisons. Thus, if possible, once the key for a field is known, it
should be used whenever possible.
</pre></div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.as_field" class="method"><a class="src rightside" href="../../src/tracing/field.rs.html#134">Source</a><h4 class="code-header">fn <a href="#tymethod.as_field" class="fn">as_field</a>(&amp;self, metadata: &amp;<a class="struct" href="../struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>&gt;</h4></section></summary><div class="docblock"><p>Attempts to convert <code>&amp;self</code> into a <code>Field</code> with the specified <code>metadata</code>.</p>
<p>If <code>metadata</code> defines this field, then the field is returned. Otherwise,
this returns <code>None</code>.</p>
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-AsField-for-str" class="impl"><a class="src rightside" href="../../src/tracing/field.rs.html#161-166">Source</a><a href="#impl-AsField-for-str" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.AsField.html" title="trait tracing::field::AsField">AsField</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a></h3></section></summary><div class="impl-items"><section id="method.as_field" class="method trait-impl"><a class="src rightside" href="../../src/tracing/field.rs.html#163-165">Source</a><a href="#method.as_field" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.as_field" class="fn">as_field</a>(&amp;self, metadata: &amp;<a class="struct" href="../struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>&gt;</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-AsField-for-%26Field" class="impl"><a class="src rightside" href="../../src/tracing/field.rs.html#150-159">Source</a><a href="#impl-AsField-for-%26Field" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.AsField.html" title="trait tracing::field::AsField">AsField</a> for &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a></h3></section><section id="impl-AsField-for-Field" class="impl"><a class="src rightside" href="../../src/tracing/field.rs.html#139-148">Source</a><a href="#impl-AsField-for-Field" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.AsField.html" title="trait tracing::field::AsField">AsField</a> for <a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a></h3></section></div><script src="../../trait.impl/tracing/field/trait.AsField.js" data-ignore-extern-crates="tracing_core,std" async></script></section></div></main></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,98 @@
<!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="Visits typed values."><title>Visit in tracing::field - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Visit</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Visit</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.record_debug" title="record_debug">record_debug</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.record_bool" title="record_bool">record_bool</a></li><li><a href="#method.record_bytes" title="record_bytes">record_bytes</a></li><li><a href="#method.record_error" title="record_error">record_error</a></li><li><a href="#method.record_f64" title="record_f64">record_f64</a></li><li><a href="#method.record_i64" title="record_i64">record_i64</a></li><li><a href="#method.record_i128" title="record_i128">record_i128</a></li><li><a href="#method.record_str" title="record_str">record_str</a></li><li><a href="#method.record_u64" title="record_u64">record_u64</a></li><li><a href="#method.record_u128" title="record_u128">record_u128</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Visit-for-DebugMap%3C'_,+'_%3E" title="DebugMap&#60;&#39;_, &#39;_&#62;">DebugMap&#60;&#39;_, &#39;_&#62;</a></li><li><a href="#impl-Visit-for-DebugStruct%3C'_,+'_%3E" title="DebugStruct&#60;&#39;_, &#39;_&#62;">DebugStruct&#60;&#39;_, &#39;_&#62;</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>field</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">field</a></div><h1>Trait <span class="trait">Visit</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing_core/field.rs.html#275">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Visit {
// Required method
fn <a href="#tymethod.record_debug" class="fn">record_debug</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>);
// Provided methods
fn <a href="#method.record_f64" class="fn">record_f64</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.f64.html">f64</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_i64" class="fn">record_i64</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.i64.html">i64</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_u64" class="fn">record_u64</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u64.html">u64</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_i128" class="fn">record_i128</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.i128.html">i128</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_u128" class="fn">record_u128</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u128.html">u128</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_bool" class="fn">record_bool</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_str" class="fn">record_str</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_bytes" class="fn">record_bytes</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) { ... }
<span class="item-spacer"></span> fn <a href="#method.record_error" class="fn">record_error</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;(dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/error/trait.Error.html" title="trait core::error::Error">Error</a> + 'static)) { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Visits typed values.</p>
<p>An instance of <code>Visit</code> (“a visitor”) represents the logic necessary to
record field values of various types. When an implementor of <a href="../trait.Value.html" title="trait tracing::Value"><code>Value</code></a> is
<a href="../trait.Value.html#tymethod.record" title="method tracing::Value::record">recorded</a>, it calls the appropriate method on the provided visitor to
indicate the type that value should be recorded as.</p>
<p>When a <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> implementation <a href="../trait.Subscriber.html#tymethod.event" title="method tracing::Subscriber::event">records an <code>Event</code></a> or a
<a href="../trait.Subscriber.html#tymethod.record" title="method tracing::Subscriber::record">set of <code>Value</code>s added to a <code>Span</code></a>, it can pass an <code>&amp;mut Visit</code> to the
<code>record</code> method on the provided <a href="struct.ValueSet.html" title="struct tracing::field::ValueSet"><code>ValueSet</code></a> or <a href="../struct.Event.html" title="struct tracing::Event"><code>Event</code></a>. This visitor
will then be used to record all the field-value pairs present on that
<code>Event</code> or <code>ValueSet</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>A simple visitor that writes to a string might be implemented like so:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::fmt::{<span class="self">self</span>, Write};
<span class="kw">use </span>tracing::field::{Value, Visit, Field};
<span class="kw">pub struct </span>StringVisitor&lt;<span class="lifetime">'a</span>&gt; {
string: <span class="kw-2">&amp;</span><span class="lifetime">'a </span><span class="kw-2">mut </span>String,
}
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; Visit <span class="kw">for </span>StringVisitor&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">fn </span>record_debug(<span class="kw-2">&amp;mut </span><span class="self">self</span>, field: <span class="kw-2">&amp;</span>Field, value: <span class="kw-2">&amp;</span><span class="kw">dyn </span>fmt::Debug) {
<span class="macro">write!</span>(<span class="self">self</span>.string, <span class="string">"{} = {:?}; "</span>, field.name(), value).unwrap();
}
}</code></pre></div>
<p>This visitor will format each recorded value using <code>fmt::Debug</code>, and
append the field name and formatted value to the provided string,
regardless of the type of the recorded value. When all the values have
been recorded, the <code>StringVisitor</code> may be dropped, allowing the string
to be printed or stored in some other data structure.</p>
<p>The <code>Visit</code> trait provides default implementations for <code>record_i64</code>,
<code>record_u64</code>, <code>record_bool</code>, <code>record_str</code>, and <code>record_error</code>, which simply
forward the recorded value to <code>record_debug</code>. Thus, <code>record_debug</code> is the
only method which a <code>Visit</code> implementation <em>must</em> implement. However,
visitors may override the default implementations of these functions in
order to implement type-specific behavior.</p>
<p>Additionally, when a visitor receives a value of a type it does not care
about, it is free to ignore those values completely. For example, a
visitor which only records numeric data might look like this:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">pub struct </span>SumVisitor {
sum: i64,
}
<span class="kw">impl </span>Visit <span class="kw">for </span>SumVisitor {
<span class="kw">fn </span>record_i64(<span class="kw-2">&amp;mut </span><span class="self">self</span>, _field: <span class="kw-2">&amp;</span>Field, value: i64) {
<span class="self">self</span>.sum += value;
}
<span class="kw">fn </span>record_u64(<span class="kw-2">&amp;mut </span><span class="self">self</span>, _field: <span class="kw-2">&amp;</span>Field, value: u64) {
<span class="self">self</span>.sum += value <span class="kw">as </span>i64;
}
<span class="kw">fn </span>record_debug(<span class="kw-2">&amp;mut </span><span class="self">self</span>, _field: <span class="kw-2">&amp;</span>Field, _value: <span class="kw-2">&amp;</span><span class="kw">dyn </span>fmt::Debug) {
<span class="comment">// Do nothing
</span>}
}</code></pre></div>
<p>This visitor (which is probably not particularly useful) keeps a running
sum of all the numeric values it records, and ignores all other values. A
more practical example of recording typed values is presented in
<code>examples/counters.rs</code>, which demonstrates a very simple metrics system
implemented using <code>tracing</code>.</p>
<div class="example-wrap" style="display:inline-block">
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: The <code>record_error</code> trait method is only
available when the Rust standard library is present, as it requires the
<code>std::error::Error</code> trait.
</pre></div>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.record_debug" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#340">Source</a><h4 class="code-header">fn <a href="#tymethod.record_debug" class="fn">record_debug</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>)</h4></section></summary><div class="docblock"><p>Visit a value implementing <code>fmt::Debug</code>.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.record_f64" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#286">Source</a><h4 class="code-header">fn <a href="#method.record_f64" class="fn">record_f64</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.f64.html">f64</a>)</h4></section></summary><div class="docblock"><p>Visit a double-precision floating point value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_i64" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#291">Source</a><h4 class="code-header">fn <a href="#method.record_i64" class="fn">record_i64</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.i64.html">i64</a>)</h4></section></summary><div class="docblock"><p>Visit a signed 64-bit integer value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_u64" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#296">Source</a><h4 class="code-header">fn <a href="#method.record_u64" class="fn">record_u64</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u64.html">u64</a>)</h4></section></summary><div class="docblock"><p>Visit an unsigned 64-bit integer value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_i128" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#301">Source</a><h4 class="code-header">fn <a href="#method.record_i128" class="fn">record_i128</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.i128.html">i128</a>)</h4></section></summary><div class="docblock"><p>Visit a signed 128-bit integer value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_u128" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#306">Source</a><h4 class="code-header">fn <a href="#method.record_u128" class="fn">record_u128</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u128.html">u128</a>)</h4></section></summary><div class="docblock"><p>Visit an unsigned 128-bit integer value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_bool" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#311">Source</a><h4 class="code-header">fn <a href="#method.record_bool" class="fn">record_bool</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>)</h4></section></summary><div class="docblock"><p>Visit a boolean value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_str" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#316">Source</a><h4 class="code-header">fn <a href="#method.record_str" class="fn">record_str</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>)</h4></section></summary><div class="docblock"><p>Visit a string value.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_bytes" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#321">Source</a><h4 class="code-header">fn <a href="#method.record_bytes" class="fn">record_bytes</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>])</h4></section></summary><div class="docblock"><p>Visit a byte slice.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_error" class="method"><a class="src rightside" href="../../src/tracing_core/field.rs.html#335">Source</a><h4 class="code-header">fn <a href="#method.record_error" class="fn">record_error</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;(dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/error/trait.Error.html" title="trait core::error::Error">Error</a> + 'static))</h4></section></summary><div class="docblock"><p>Records a type implementing <code>Error</code>.</p>
<div class="example-wrap" style="display:inline-block">
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: This is only enabled when the Rust standard library is
present.
</pre>
</div></div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Visit-for-DebugMap%3C'_,+'_%3E" class="impl"><a class="src rightside" href="../../src/tracing_core/field.rs.html#425">Source</a><a href="#impl-Visit-for-DebugMap%3C'_,+'_%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Visit.html" title="trait tracing::field::Visit">Visit</a> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/builders/struct.DebugMap.html" title="struct core::fmt::builders::DebugMap">DebugMap</a>&lt;'_, '_&gt;</h3></section></summary><div class="impl-items"><section id="method.record_debug" class="method trait-impl"><a class="src rightside" href="../../src/tracing_core/field.rs.html#426">Source</a><a href="#method.record_debug" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.record_debug" class="fn">record_debug</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>)</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Visit-for-DebugStruct%3C'_,+'_%3E" class="impl"><a class="src rightside" href="../../src/tracing_core/field.rs.html#419">Source</a><a href="#impl-Visit-for-DebugStruct%3C'_,+'_%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Visit.html" title="trait tracing::field::Visit">Visit</a> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/builders/struct.DebugStruct.html" title="struct core::fmt::builders::DebugStruct">DebugStruct</a>&lt;'_, '_&gt;</h3></section></summary><div class="impl-items"><section id="method.record_debug-1" class="method trait-impl"><a class="src rightside" href="../../src/tracing_core/field.rs.html#420">Source</a><a href="#method.record_debug-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.record_debug" class="fn">record_debug</a>(&amp;mut self, field: &amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, value: &amp;dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>)</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Visit-for-F" class="impl"><a class="src rightside" href="../../src/tracing_core/field.rs.html#431-433">Source</a><a href="#impl-Visit-for-F" class="anchor">§</a><h3 class="code-header">impl&lt;F&gt; <a class="trait" href="trait.Visit.html" title="trait tracing::field::Visit">Visit</a> for F<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;<a class="struct" href="struct.Field.html" title="struct tracing::field::Field">Field</a>, &amp;dyn <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>),</div></h3></section></div><script src="../../trait.impl/tracing_core/field/trait.Visit.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,566 @@
<!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="A scoped, structured logging and diagnostics system."><title>tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></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]--><rustdoc-topbar><h2><a href="#">Crate tracing</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#overview" title="Overview">Overview</a></li><li><a href="#core-concepts" title="Core Concepts">Core Concepts</a><ul><li><a href="#spans" title="Spans">Spans</a></li><li><a href="#events" title="Events">Events</a></li><li><a href="#subscribers" title="Subscribers">Subscribers</a></li></ul></li><li><a href="#usage" title="Usage">Usage</a><ul><li><a href="#recording-spans-and-events" title="Recording Spans and Events">Recording Spans and Events</a></li><li><a href="#using-the-macros" title="Using the Macros">Using the Macros</a></li><li><a href="#in-libraries" title="In libraries">In libraries</a></li><li><a href="#in-executables" title="In executables">In executables</a></li><li><a href="#log-compatibility" title="`log` Compatibility"><code>log</code> Compatibility</a></li><li><a href="#related-crates" title="Related Crates">Related Crates</a></li><li><a href="#crate-feature-flags" title="Crate Feature Flags">Crate Feature Flags</a></li><li><a href="#supported-rust-versions" title="Supported Rust Versions">Supported Rust Versions</a></li></ul></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#attributes" title="Attribute Macros">Attribute Macros</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>tracing</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/lib.rs.html#1-1205">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A scoped, structured logging and diagnostics system.</p>
<h2 id="overview"><a class="doc-anchor" href="#overview">§</a>Overview</h2>
<p><code>tracing</code> is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information.</p>
<p>In asynchronous systems like Tokio, interpreting traditional log messages can
often be quite challenging. Since individual tasks are multiplexed on the same
thread, associated events and log lines are intermixed making it difficult to
trace the logic flow. <code>tracing</code> expands upon logging-style diagnostics by
allowing libraries and applications to record structured events with additional
information about <em>temporality</em> and <em>causality</em> — unlike a log message, a span
in <code>tracing</code> has a beginning and end time, may be entered and exited by the
flow of execution, and may exist within a nested tree of similar spans. In
addition, <code>tracing</code> spans are <em>structured</em>, with the ability to record typed
data as well as textual messages.</p>
<p>The <code>tracing</code> crate provides the APIs necessary for instrumenting libraries
and applications to emit trace data.</p>
<p><em>Compiler support: <a href="#supported-rust-versions">requires <code>rustc</code> 1.65+</a></em></p>
<h2 id="core-concepts"><a class="doc-anchor" href="#core-concepts">§</a>Core Concepts</h2>
<p>The core of <code>tracing</code>s API is composed of <em>spans</em>, <em>events</em> and
<em>subscribers</em>. Well cover these in turn.</p>
<h3 id="spans"><a class="doc-anchor" href="#spans">§</a>Spans</h3>
<p>To record the flow of execution through a program, <code>tracing</code> introduces the
concept of <a href="span/index.html" title="mod tracing::span">spans</a>. Unlike a log line that represents a <em>moment in
time</em>, a span represents a <em>period of time</em> with a beginning and an end. When a
program begins executing in a context or performing a unit of work, it
<em>enters</em> that contexts span, and when it stops executing in that context,
it <em>exits</em> the span. The span in which a thread is currently executing is
referred to as that threads <em>current</em> span.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{span, Level};
<span class="kw">let </span>span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my_span"</span>);
<span class="comment">// `enter` returns a RAII guard which, when dropped, exits the span. this
// indicates that we are in the span for the current lexical scope.
</span><span class="kw">let </span>_enter = span.enter();
<span class="comment">// perform some work in the context of `my_span`...</span></code></pre></div>
<p>The <a href="span/index.html" title="mod tracing::span"><code>span</code> module</a>s documentation provides further details on how to
use spans.</p>
<div class="example-wrap" style="display:inline-block"><pre class="compile_fail" style="white-space:normal;font:inherit;">
<p><strong>Warning</strong>: In asynchronous code that uses async/await syntax,
<code>Span::enter</code> may produce incorrect traces if the returned drop
guard is held across an await point. See
<a href="struct.Span.html#in-asynchronous-code" title="struct tracing::Span">the method documentation</a> for details.</p>
<p></pre></div></p>
<h3 id="events"><a class="doc-anchor" href="#events">§</a>Events</h3>
<p>An <a href="struct.Event.html" title="struct tracing::Event"><code>Event</code></a> represents a <em>moment</em> in time. It signifies something that
happened while a trace was being recorded. <code>Event</code>s are comparable to the log
records emitted by unstructured logging code, but unlike a typical log line,
an <code>Event</code> may occur within the context of a span.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{event, span, Level};
<span class="comment">// records an event outside of any span context:
</span><span class="macro">event!</span>(Level::INFO, <span class="string">"something happened"</span>);
<span class="kw">let </span>span = <span class="macro">span!</span>(Level::INFO, <span class="string">"my_span"</span>);
<span class="kw">let </span>_guard = span.enter();
<span class="comment">// records an event within "my_span".
</span><span class="macro">event!</span>(Level::DEBUG, <span class="string">"something happened inside my_span"</span>);</code></pre></div>
<p>In general, events should be used to represent points in time <em>within</em> a
span — a request returned with a given status code, <em>n</em> new items were
taken from a queue, and so on.</p>
<p>The <a href="struct.Event.html" title="struct tracing::Event"><code>Event</code> struct</a> documentation provides further details on using
events.</p>
<h3 id="subscribers"><a class="doc-anchor" href="#subscribers">§</a>Subscribers</h3>
<p>As <code>Span</code>s and <code>Event</code>s occur, they are recorded or aggregated by
implementations of the <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> trait. <code>Subscriber</code>s are notified
when an <code>Event</code> takes place and when a <code>Span</code> is entered or exited. These
notifications are represented by the following <code>Subscriber</code> trait methods:</p>
<ul>
<li><a href="trait.Subscriber.html#tymethod.event" title="method tracing::Subscriber::event"><code>event</code></a>, called when an <code>Event</code> takes place,</li>
<li><a href="trait.Subscriber.html#tymethod.enter" title="method tracing::Subscriber::enter"><code>enter</code></a>, called when execution enters a <code>Span</code>,</li>
<li><a href="trait.Subscriber.html#tymethod.exit" title="method tracing::Subscriber::exit"><code>exit</code></a>, called when execution exits a <code>Span</code></li>
</ul>
<p>In addition, subscribers may implement the <a href="trait.Subscriber.html#tymethod.enabled" title="method tracing::Subscriber::enabled"><code>enabled</code></a> function to <em>filter</em>
the notifications they receive based on <a href="struct.Metadata.html" title="struct tracing::Metadata">metadata</a> describing each <code>Span</code>
or <code>Event</code>. If a call to <code>Subscriber::enabled</code> returns <code>false</code> for a given
set of metadata, that <code>Subscriber</code> will <em>not</em> be notified about the
corresponding <code>Span</code> or <code>Event</code>. For performance reasons, if no currently
active subscribers express interest in a given set of metadata by returning
<code>true</code>, then the corresponding <code>Span</code> or <code>Event</code> will never be constructed.</p>
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
<p>First, add this to your <code>Cargo.toml</code>:</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
tracing = &quot;0.1&quot;</code></pre></div><h3 id="recording-spans-and-events"><a class="doc-anchor" href="#recording-spans-and-events">§</a>Recording Spans and Events</h3>
<p>Spans and events are recorded using macros.</p>
<h4 id="spans-1"><a class="doc-anchor" href="#spans-1">§</a>Spans</h4>
<p>The <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a> macro expands to a <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code> struct</a> which is used to
record a span. The <a href="struct.Span.html#method.enter" title="method tracing::Span::enter"><code>Span::enter</code></a> method on that struct records that the
span has been entered, and returns a <a href="https://github.com/rust-unofficial/patterns/blob/main/src/patterns/behavioural/RAII.md">RAII</a> guard object, which will exit
the span when dropped.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{span, Level};
<span class="comment">// Construct a new span named "my span" with trace log level.
</span><span class="kw">let </span>span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my span"</span>);
<span class="comment">// Enter the span, returning a guard object.
</span><span class="kw">let </span>_enter = span.enter();
<span class="comment">// Any trace events that occur before the guard is dropped will occur
// within the span.
// Dropping the guard will exit the span.</span></code></pre></div>
<p>The <a href="https://docs.rs/tracing-attributes/latest/tracing_attributes/attr.instrument.html"><code>#[instrument]</code></a> attribute provides an easy way to
add <code>tracing</code> spans to functions. A function annotated with <code>#[instrument]</code>
will create and enter a span with that functions name every time the
function is called, with arguments to that function will be recorded as
fields using <code>fmt::Debug</code>.</p>
<p>For example:</p>
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{Level, event, instrument};
<span class="attr">#[instrument]
</span><span class="kw">pub fn </span>my_function(my_arg: usize) {
<span class="comment">// This event will be recorded inside a span named `my_function` with the
// field `my_arg`.
</span><span class="macro">event!</span>(Level::INFO, <span class="string">"inside my_function!"</span>);
<span class="comment">// ...
</span>}</code></pre></div>
<p>For functions which dont have built-in tracing support and cant have
the <code>#[instrument]</code> attribute applied (such as from an external crate),
the <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code> struct</a> has a <a href="struct.Span.html#method.in_scope" title="method tracing::Span::in_scope"><code>in_scope()</code> method</a>
which can be used to easily wrap synchronous code in a span.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::info_span;
<span class="kw">let </span>json = <span class="macro">info_span!</span>(<span class="string">"json.parse"</span>).in_scope(|| serde_json::from_slice(<span class="kw-2">&amp;</span>buf))<span class="question-mark">?</span>;</code></pre></div>
<p>You can find more examples showing how to use this crate <a href="https://github.com/tokio-rs/tracing/tree/main/examples">here</a>.</p>
<h4 id="events-1"><a class="doc-anchor" href="#events-1">§</a>Events</h4>
<p><a href="struct.Event.html" title="struct tracing::Event"><code>Event</code></a>s are recorded using the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{event, Level};
<span class="macro">event!</span>(Level::INFO, <span class="string">"something has happened!"</span>);</code></pre></div><h3 id="using-the-macros"><a class="doc-anchor" href="#using-the-macros">§</a>Using the Macros</h3>
<p>The <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a> and <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macros as well as the <code>#[instrument]</code> attribute
use fairly similar syntax, with some exceptions.</p>
<h4 id="configuring-attributes"><a class="doc-anchor" href="#configuring-attributes">§</a>Configuring Attributes</h4>
<p>Both macros require a <a href="struct.Level.html" title="struct tracing::Level"><code>Level</code></a> specifying the verbosity of the span or
event. Optionally, the, <a href="struct.Metadata.html#method.target" title="method tracing::Metadata::target">target</a> and <a href="span/struct.Attributes.html#method.parent" title="method tracing::span::Attributes::parent">parent span</a> may be overridden. If the
target and parent span are not overridden, they will default to the
module path where the macro was invoked and the current span (as determined
by the subscriber), respectively.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">span!</span>(target: <span class="string">"app_spans"</span>, Level::TRACE, <span class="string">"my span"</span>);
<span class="macro">event!</span>(target: <span class="string">"app_events"</span>, Level::INFO, <span class="string">"something has happened!"</span>);</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my span"</span>);
<span class="macro">event!</span>(parent: <span class="kw-2">&amp;</span>span, Level::INFO, <span class="string">"something has happened!"</span>);</code></pre></div>
<p>The span macros also take a string literal after the level, to set the name
of the span (as above). In the case of the event macros, the name of the event can
be overridden (the default is <code>event file:line</code>) using the <code>name:</code> specifier.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">span!</span>(Level::TRACE, <span class="string">"my span"</span>);
<span class="macro">event!</span>(name: <span class="string">"some_info"</span>, Level::INFO, <span class="string">"something has happened!"</span>);</code></pre></div><h4 id="recording-fields"><a class="doc-anchor" href="#recording-fields">§</a>Recording Fields</h4>
<p>Structured fields on spans and events are specified using the syntax
<code>field_name = field_value</code>. Fields are separated by commas.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// records an event with two fields:
// - "answer", with the value 42
// - "question", with the value "life, the universe and everything"
</span><span class="macro">event!</span>(Level::INFO, answer = <span class="number">42</span>, question = <span class="string">"life, the universe, and everything"</span>);</code></pre></div>
<p>As shorthand, local variables may be used as field values without an
assignment, similar to <a href="https://doc.rust-lang.org/book/ch05-01-defining-structs.html#using-the-field-init-shorthand-when-variables-and-fields-have-the-same-name">struct initializers</a>. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>user = <span class="string">"ferris"</span>;
<span class="macro">span!</span>(Level::TRACE, <span class="string">"login"</span>, user);
<span class="comment">// is equivalent to:
</span><span class="macro">span!</span>(Level::TRACE, <span class="string">"login"</span>, user = user);</code></pre></div>
<p>Field names can include dots, but should not be terminated by them:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>user = <span class="string">"ferris"</span>;
<span class="kw">let </span>email = <span class="string">"ferris@rust-lang.org"</span>;
<span class="macro">span!</span>(Level::TRACE, <span class="string">"login"</span>, user, user.email = email);</code></pre></div>
<p>Since field names can include dots, fields on local structs can be used
using the local variable shorthand:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>user = User {
name: <span class="string">"ferris"</span>,
email: <span class="string">"ferris@rust-lang.org"</span>,
};
<span class="comment">// the span will have the fields `user.name = "ferris"` and
// `user.email = "ferris@rust-lang.org"`.
</span><span class="macro">span!</span>(Level::TRACE, <span class="string">"login"</span>, user.name, user.email);</code></pre></div>
<p>Fields with names that are not Rust identifiers, or with names that are Rust reserved words,
may be created using quoted string literals. However, this may not be used with the local
variable shorthand.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// records an event with fields whose names are not Rust identifiers
// - "guid:x-request-id", containing a `:`, with the value "abcdef"
// - "type", which is a reserved word, with the value "request"
</span><span class="macro">span!</span>(Level::TRACE, <span class="string">"api"</span>, <span class="string">"guid:x-request-id" </span>= <span class="string">"abcdef"</span>, <span class="string">"type" </span>= <span class="string">"request"</span>);</code></pre></div>
<p>Constant expressions can also be used as field names. Constants
must be enclosed in curly braces (<code>{}</code>) to indicate that the <em>value</em>
of the constant is to be used as the field name, rather than the
constants name. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">const </span>RESOURCE_NAME: <span class="kw-2">&amp;</span>str = <span class="string">"foo"</span>;
<span class="comment">// this span will have the field `foo = "some_id"`
</span><span class="macro">span!</span>(Level::TRACE, <span class="string">"get"</span>, { RESOURCE_NAME } = <span class="string">"some_id"</span>);</code></pre></div>
<p>The <code>?</code> sigil is shorthand that specifies a field should be recorded using
its <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug"><code>fmt::Debug</code></a> implementation:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[derive(Debug)]
</span><span class="kw">struct </span>MyStruct {
field: <span class="kw-2">&amp;</span><span class="lifetime">'static </span>str,
}
<span class="kw">let </span>my_struct = MyStruct {
field: <span class="string">"Hello world!"
</span>};
<span class="comment">// `my_struct` will be recorded using its `fmt::Debug` implementation.
</span><span class="macro">event!</span>(Level::TRACE, greeting = <span class="question-mark">?</span>my_struct);
<span class="comment">// is equivalent to:
</span><span class="macro">event!</span>(Level::TRACE, greeting = tracing::field::debug(<span class="kw-2">&amp;</span>my_struct));</code></pre></div>
<p>The <code>%</code> sigil operates similarly, but indicates that the value should be
recorded using its <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Display.html" title="trait core::fmt::Display"><code>fmt::Display</code></a> implementation:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// `my_struct.field` will be recorded using its `fmt::Display` implementation.
</span><span class="macro">event!</span>(Level::TRACE, greeting = %my_struct.field);
<span class="comment">// is equivalent to:
</span><span class="macro">event!</span>(Level::TRACE, greeting = tracing::field::display(<span class="kw-2">&amp;</span>my_struct.field));</code></pre></div>
<p>The <code>%</code> and <code>?</code> sigils may also be used with local variable shorthand:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// `my_struct.field` will be recorded using its `fmt::Display` implementation.
</span><span class="macro">event!</span>(Level::TRACE, %my_struct.field);</code></pre></div>
<p>Additionally, a span may declare fields with the special value <a href="field/struct.Empty.html" title="struct tracing::field::Empty"><code>Empty</code></a>,
which indicates that that the value for that field does not currently exist
but may be recorded later. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{trace_span, field};
<span class="comment">// Create a span with two fields: `greeting`, with the value "hello world", and
// `parting`, without a value.
</span><span class="kw">let </span>span = <span class="macro">trace_span!</span>(<span class="string">"my_span"</span>, greeting = <span class="string">"hello world"</span>, parting = field::Empty);
<span class="comment">// ...
// Now, record a value for parting as well.
</span>span.record(<span class="string">"parting"</span>, <span class="kw-2">&amp;</span><span class="string">"goodbye world!"</span>);</code></pre></div>
<p>Finally, events may also include human-readable messages, in the form of a
<a href="https://doc.rust-lang.org/1.93.1/alloc/fmt/index.html#usage" title="mod alloc::fmt">format string</a> and (optional) arguments, <strong>after</strong> the events
key-value fields. If a format string and arguments are provided,
they will implicitly create a new field named <code>message</code> whose value is the
provided set of format arguments.</p>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>question = <span class="string">"the ultimate question of life, the universe, and everything"</span>;
<span class="kw">let </span>answer = <span class="number">42</span>;
<span class="comment">// records an event with the following fields:
// - `question.answer` with the value 42,
// - `question.tricky` with the value `true`,
// - "message", with the value "the answer to the ultimate question of life, the
// universe, and everything is 42."
</span><span class="macro">event!</span>(
Level::DEBUG,
question.answer = answer,
question.tricky = <span class="bool-val">true</span>,
<span class="string">"the answer to {} is {}."</span>, question, answer
);</code></pre></div>
<p>Specifying a formatted message in this manner does not allocate by default.</p>
<h4 id="shorthand-macros"><a class="doc-anchor" href="#shorthand-macros">§</a>Shorthand Macros</h4>
<p><code>tracing</code> also offers a number of macros with preset verbosity levels.
The <a href="macro.trace.html" title="macro tracing::trace"><code>trace!</code></a>, <a href="macro.debug.html" title="macro tracing::debug"><code>debug!</code></a>, <a href="macro.info.html" title="macro tracing::info"><code>info!</code></a>, <a href="macro.warn.html" title="macro tracing::warn"><code>warn!</code></a>, and <a href="macro.error.html" title="macro tracing::error"><code>error!</code></a> behave
similarly to the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro, but with the <a href="struct.Level.html" title="struct tracing::Level"><code>Level</code></a> argument already
specified, while the corresponding <a href="macro.trace_span.html" title="macro tracing::trace_span"><code>trace_span!</code></a>, <a href="macro.debug_span.html" title="macro tracing::debug_span"><code>debug_span!</code></a>,
<a href="macro.info_span.html" title="macro tracing::info_span"><code>info_span!</code></a>, <a href="macro.warn_span.html" title="macro tracing::warn_span"><code>warn_span!</code></a>, and <a href="macro.error_span.html" title="macro tracing::error_span"><code>error_span!</code></a> macros are the same,
but for the <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a> macro.</p>
<p>These are intended both as a shorthand, and for compatibility with the <a href="https://docs.rs/log/0.4.6/log/"><code>log</code></a>
crate (see the next section).</p>
<h4 id="for-log-users"><a class="doc-anchor" href="#for-log-users">§</a>For <code>log</code> Users</h4>
<p>Users of the <a href="https://docs.rs/log/0.4.6/log/"><code>log</code></a> crate should note that <code>tracing</code> exposes a set of
macros for creating <code>Event</code>s (<code>trace!</code>, <code>debug!</code>, <code>info!</code>, <code>warn!</code>, and
<code>error!</code>) which may be invoked with the same syntax as the similarly-named
macros from the <code>log</code> crate. Often, the process of converting a project to
use <code>tracing</code> can begin with a simple drop-in replacement.</p>
<p>Lets consider the <code>log</code> crates yak-shaving example:</p>
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::{error::Error, io};
<span class="kw">use </span>tracing::{debug, error, info, span, warn, Level};
<span class="comment">// the `#[tracing::instrument]` attribute creates and enters a span
// every time the instrumented function is called. The span is named after the
// the function or method. Parameters passed to the function are recorded as fields.
</span><span class="attr">#[tracing::instrument]
</span><span class="kw">pub fn </span>shave(yak: usize) -&gt; <span class="prelude-ty">Result</span>&lt;(), Box&lt;<span class="kw">dyn </span>Error + <span class="lifetime">'static</span>&gt;&gt; {
<span class="comment">// this creates an event at the DEBUG level with two fields:
// - `excitement`, with the key "excitement" and the value "yay!"
// - `message`, with the key "message" and the value "hello! I'm gonna shave a yak."
//
// unlike other fields, `message`'s shorthand initialization is just the string itself.
</span><span class="macro">debug!</span>(excitement = <span class="string">"yay!"</span>, <span class="string">"hello! I'm gonna shave a yak."</span>);
<span class="kw">if </span>yak == <span class="number">3 </span>{
<span class="macro">warn!</span>(<span class="string">"could not locate yak!"</span>);
<span class="comment">// note that this is intended to demonstrate `tracing`'s features, not idiomatic
// error handling! in a library or application, you should consider returning
// a dedicated `YakError`. libraries like snafu or thiserror make this easy.
</span><span class="kw">return </span><span class="prelude-val">Err</span>(io::Error::new(io::ErrorKind::Other, <span class="string">"shaving yak failed!"</span>).into());
} <span class="kw">else </span>{
<span class="macro">debug!</span>(<span class="string">"yak shaved successfully"</span>);
}
<span class="prelude-val">Ok</span>(())
}
<span class="kw">pub fn </span>shave_all(yaks: usize) -&gt; usize {
<span class="comment">// Constructs a new span named "shaving_yaks" at the TRACE level,
// and a field whose key is "yaks". This is equivalent to writing:
//
// let span = span!(Level::TRACE, "shaving_yaks", yaks = yaks);
//
// local variables (`yaks`) can be used as field values
// without an assignment, similar to struct initializers.
</span><span class="kw">let </span>_span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"shaving_yaks"</span>, yaks).entered();
<span class="macro">info!</span>(<span class="string">"shaving yaks"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>yaks_shaved = <span class="number">0</span>;
<span class="kw">for </span>yak <span class="kw">in </span><span class="number">1</span>..=yaks {
<span class="kw">let </span>res = shave(yak);
<span class="macro">debug!</span>(yak, shaved = res.is_ok());
<span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw-2">ref </span>error) = res {
<span class="comment">// Like spans, events can also use the field initialization shorthand.
// In this instance, `yak` is the field being initalized.
</span><span class="macro">error!</span>(yak, error = error.as_ref(), <span class="string">"failed to shave yak!"</span>);
} <span class="kw">else </span>{
yaks_shaved += <span class="number">1</span>;
}
<span class="macro">debug!</span>(yaks_shaved);
}
yaks_shaved
}</code></pre></div><h3 id="in-libraries"><a class="doc-anchor" href="#in-libraries">§</a>In libraries</h3>
<p>Libraries should link only to the <code>tracing</code> crate, and use the provided
macros to record whatever information will be useful to downstream
consumers.</p>
<h3 id="in-executables"><a class="doc-anchor" href="#in-executables">§</a>In executables</h3>
<p>In order to record trace events, executables have to use a <code>Subscriber</code>
implementation compatible with <code>tracing</code>. A <code>Subscriber</code> implements a
way of collecting trace data, such as by logging it to standard output.</p>
<p>This library does not contain any <code>Subscriber</code> implementations; these are
provided by <a href="#related-crates">other crates</a>.</p>
<p>The simplest way to use a subscriber is to call the <a href="subscriber/fn.set_global_default.html" title="fn tracing::subscriber::set_global_default"><code>set_global_default</code></a>
function:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">extern crate </span>tracing;
<span class="kw">let </span>my_subscriber = FooSubscriber::new();
tracing::subscriber::set_global_default(my_subscriber)
.expect(<span class="string">"setting tracing default failed"</span>);</code></pre></div> <pre class="compile_fail" style="white-space:normal;font:inherit;">
<strong>Warning</strong>: In general, libraries should <em>not</em> call
<code>set_global_default()</code>! Doing so will cause conflicts when
executables that depend on the library try to set the default later.
</pre>
<p>This subscriber will be used as the default in all threads for the
remainder of the duration of the program, similar to setting the logger
in the <code>log</code> crate.</p>
<p>In addition, the default subscriber can be set through using the
<a href="subscriber/fn.with_default.html" title="fn tracing::subscriber::with_default"><code>with_default</code></a> function. This follows the <code>tokio</code> pattern of using
closures to represent executing code in a context that is exited at the end
of the closure. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>my_subscriber = FooSubscriber::new();
tracing::subscriber::with_default(my_subscriber, || {
<span class="comment">// Any trace events generated in this closure or by functions it calls
// will be collected by `my_subscriber`.
</span>})</code></pre></div>
<p>This approach allows trace data to be collected by multiple subscribers
within different contexts in the program. Note that the override only applies to the
currently executing thread; other threads will not see the change from with_default.</p>
<p>Any trace events generated outside the context of a subscriber will not be collected.</p>
<p>Once a subscriber has been set, instrumentation points may be added to the
executable using the <code>tracing</code> crates macros.</p>
<h3 id="log-compatibility"><a class="doc-anchor" href="#log-compatibility">§</a><code>log</code> Compatibility</h3>
<p>The <a href="https://docs.rs/log/0.4.6/log/"><code>log</code></a> crate provides a simple, lightweight logging facade for Rust.
While <code>tracing</code> builds upon <code>log</code>s foundation with richer structured
diagnostic data, <code>log</code>s simplicity and ubiquity make it the “lowest common
denominator” for text-based logging in Rust — a vast majority of Rust
libraries and applications either emit or consume <code>log</code> records. Therefore,
<code>tracing</code> provides multiple forms of interoperability with <code>log</code>: <code>tracing</code>
instrumentation can emit <code>log</code> records, and a compatibility layer enables
<code>tracing</code> <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>s to consume <code>log</code> records as <code>tracing</code> <a href="struct.Event.html" title="struct tracing::Event"><code>Event</code></a>s.</p>
<h4 id="emitting-log-records"><a class="doc-anchor" href="#emitting-log-records">§</a>Emitting <code>log</code> Records</h4>
<p>This crate provides two feature flags, “log” and “log-always”, which will
cause <a href="span/index.html" title="mod tracing::span">spans</a> and <a href="struct.Event.html" title="struct tracing::Event">events</a> to emit <code>log</code> records. When the “log” feature is
enabled, if no <code>tracing</code> <code>Subscriber</code> is active, invoking an event macro or
creating a span with fields will emit a <code>log</code> record. This is intended
primarily for use in libraries which wish to emit diagnostics that can be
consumed by applications using <code>tracing</code> <em>or</em> <code>log</code>, without paying the
additional overhead of emitting both forms of diagnostics when <code>tracing</code> is
in use.</p>
<p>Enabling the “log-always” feature will cause <code>log</code> records to be emitted
even if a <code>tracing</code> <code>Subscriber</code> <em>is</em> set. This is intended to be used in
applications where a <code>log</code> <code>Logger</code> is being used to record a textual log,
and <code>tracing</code> is used only to record other forms of diagnostics (such as
metrics, profiling, or distributed tracing data). Unlike the “log” feature,
libraries generally should <strong>not</strong> enable the “log-always” feature, as doing
so will prevent applications from being able to opt out of the <code>log</code> records.</p>
<p>See <a href="#crate-feature-flags">here</a> for more details on this crates feature flags.</p>
<p>The generated <code>log</code> records messages will be a string representation of the
span or events fields, and all additional information recorded by <code>log</code>
(target, verbosity level, module path, file, and line number) will also be
populated. Additionally, <code>log</code> records are also generated when spans are
entered, exited, and closed. Since these additional span lifecycle logs have
the potential to be very verbose, and dont include additional fields, they
will always be emitted at the <code>Trace</code> level, rather than inheriting the
level of the span that generated them. Furthermore, they are categorized
under a separate <code>log</code> target, “tracing::span” (and its sub-target,
“tracing::span::active”, for the logs on entering and exiting a span), which
may be enabled or disabled separately from other <code>log</code> records emitted by
<code>tracing</code>.</p>
<h4 id="consuming-log-records"><a class="doc-anchor" href="#consuming-log-records">§</a>Consuming <code>log</code> Records</h4>
<p>The <a href="https://crates.io/crates/tracing-log"><code>tracing-log</code></a> crate provides a compatibility layer which
allows a <code>tracing</code> <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> to consume <code>log</code> records as though they
were <code>tracing</code> <a href="struct.Event.html" title="struct tracing::Event">events</a>. This allows applications using <code>tracing</code> to record
the logs emitted by dependencies using <code>log</code> as events within the context of
the applications trace tree. See <a href="https://docs.rs/tracing-log/latest/tracing_log/#convert-log-records-to-tracing-events">that crates documentation</a>
for details.</p>
<h3 id="related-crates"><a class="doc-anchor" href="#related-crates">§</a>Related Crates</h3>
<p>In addition to <code>tracing</code> and <code>tracing-core</code>, the <a href="https://github.com/tokio-rs/tracing"><code>tokio-rs/tracing</code></a> repository
contains several additional crates designed to be used with the <code>tracing</code> ecosystem.
This includes a collection of <code>Subscriber</code> implementations, as well as utility
and adapter crates to assist in writing <code>Subscriber</code>s and instrumenting
applications.</p>
<p>In particular, the following crates are likely to be of interest:</p>
<ul>
<li><a href="https://crates.io/crates/tracing-futures"><code>tracing-futures</code></a> provides a compatibility layer with the <code>futures</code>
crate, allowing spans to be attached to <code>Future</code>s, <code>Stream</code>s, and <code>Executor</code>s.</li>
<li><a href="https://crates.io/crates/tracing-subscriber"><code>tracing-subscriber</code></a> provides <code>Subscriber</code> implementations and
utilities for working with <code>Subscriber</code>s. This includes a <a href="https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Subscriber.html"><code>FmtSubscriber</code></a>
<code>FmtSubscriber</code> for logging formatted trace data to stdout, with similar
filtering and formatting to the <a href="https://crates.io/crates/env_logger"><code>env_logger</code></a> crate.</li>
<li><a href="https://crates.io/crates/tracing-log"><code>tracing-log</code></a> provides a compatibility layer with the <a href="https://docs.rs/log/0.4.6/log/"><code>log</code></a> crate,
allowing log messages to be recorded as <code>tracing</code> <code>Event</code>s within the
trace tree. This is useful when a project using <code>tracing</code> have
dependencies which use <code>log</code>. Note that if youre using
<code>tracing-subscriber</code>s <code>FmtSubscriber</code>, you dont need to depend on
<code>tracing-log</code> directly.</li>
<li><a href="https://crates.io/crates/tracing-appender"><code>tracing-appender</code></a> provides utilities for outputting tracing data,
including a file appender and non blocking writer.</li>
</ul>
<p>Additionally, there are also several third-party crates which are not
maintained by the <code>tokio</code> project. These include:</p>
<ul>
<li><a href="https://crates.io/crates/tracing-timing"><code>tracing-timing</code></a> implements inter-event timing metrics on top of <code>tracing</code>.
It provides a subscriber that records the time elapsed between pairs of
<code>tracing</code> events and generates histograms.</li>
<li><a href="https://crates.io/crates/tracing-opentelemetry"><code>tracing-opentelemetry</code></a> provides a subscriber for emitting traces to
<a href="https://opentelemetry.io/">OpenTelemetry</a>-compatible distributed tracing systems.</li>
<li><a href="https://crates.io/crates/tracing-honeycomb"><code>tracing-honeycomb</code></a> Provides a layer that reports traces spanning multiple machines to <a href="https://www.honeycomb.io/">honeycomb.io</a>. Backed by <a href="https://crates.io/crates/tracing-distributed"><code>tracing-distributed</code></a>.</li>
<li><a href="https://crates.io/crates/tracing-distributed"><code>tracing-distributed</code></a> Provides a generic implementation of a layer that reports traces spanning multiple machines to some backend.</li>
<li><a href="https://crates.io/crates/tracing-actix-web"><code>tracing-actix-web</code></a> provides <code>tracing</code> integration for the <code>actix-web</code> web framework.</li>
<li><a href="https://crates.io/crates/tracing-actix"><code>tracing-actix</code></a> provides <code>tracing</code> integration for the <code>actix</code> actor
framework.</li>
<li><a href="https://crates.io/crates/axum-insights"><code>axum-insights</code></a> provides <code>tracing</code> integration and Application insights export for the <code>axum</code> web framework.</li>
<li><a href="https://crates.io/crates/tracing-gelf"><code>tracing-gelf</code></a> implements a subscriber for exporting traces in Greylog
GELF format.</li>
<li><a href="https://crates.io/crates/tracing-coz"><code>tracing-coz</code></a> provides integration with the <a href="https://github.com/plasma-umass/coz">coz</a> causal profiler
(Linux-only).</li>
<li><a href="https://crates.io/crates/tracing-bunyan-formatter"><code>tracing-bunyan-formatter</code></a> provides a layer implementation that reports events and spans
in <a href="https://github.com/trentm/node-bunyan">bunyan</a> format, enriched with timing information.</li>
<li><a href="https://docs.rs/tracing-wasm"><code>tracing-wasm</code></a> provides a <code>Subscriber</code>/<code>Layer</code> implementation that reports
events and spans via browser <code>console.log</code> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API">User Timing API (<code>window.performance</code>)</a>.</li>
<li><a href="https://docs.rs/tracing-web"><code>tracing-web</code></a> provides a layer implementation of level-aware logging of events
to web browsers <code>console.*</code> and span events to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API">User Timing API (<code>window.performance</code>)</a>.</li>
<li><a href="https://crates.io/crates/tide-tracing"><code>tide-tracing</code></a> provides a <a href="https://crates.io/crates/tide">tide</a> middleware to trace all incoming requests and responses.</li>
<li><a href="https://crates.io/crates/test-log"><code>test-log</code></a> takes care of initializing <code>tracing</code> for tests, based on
environment variables with an <code>env_logger</code> compatible syntax.</li>
<li><a href="https://docs.rs/tracing-unwrap"><code>tracing-unwrap</code></a> provides convenience methods to report failed unwraps
on <code>Result</code> or <code>Option</code> types to a <code>Subscriber</code>.</li>
<li><a href="https://crates.io/crates/diesel-tracing"><code>diesel-tracing</code></a> provides integration with <a href="https://crates.io/crates/diesel"><code>diesel</code></a> database connections.</li>
<li><a href="https://crates.io/crates/tracing-tracy"><code>tracing-tracy</code></a> provides a way to collect <a href="https://github.com/wolfpld/tracy">Tracy</a> profiles in instrumented
applications.</li>
<li><a href="https://crates.io/crates/tracing-elastic-apm"><code>tracing-elastic-apm</code></a> provides a layer for reporting traces to <a href="https://www.elastic.co/apm">Elastic APM</a>.</li>
<li><a href="https://github.com/microsoft/rust_win_etw/tree/main/win_etw_tracing"><code>tracing-etw</code></a> provides a layer for emitting Windows <a href="https://docs.microsoft.com/en-us/windows/win32/etw/about-event-tracing">ETW</a> events.</li>
<li><a href="https://crates.io/crates/tracing-fluent-assertions"><code>tracing-fluent-assertions</code></a> provides a fluent assertions-style testing
framework for validating the behavior of <code>tracing</code> spans.</li>
<li><a href="https://crates.io/crates/sentry-tracing"><code>sentry-tracing</code></a> provides a layer for reporting events and traces to <a href="https://sentry.io/welcome/">Sentry</a>.</li>
<li><a href="https://crates.io/crates/tracing-forest"><code>tracing-forest</code></a> provides a subscriber that preserves contextual coherence by
grouping together logs from the same spans during writing.</li>
<li><a href="https://crates.io/crates/tracing-loki"><code>tracing-loki</code></a> provides a layer for shipping logs to <a href="https://grafana.com/oss/loki/">Grafana Loki</a>.</li>
<li><a href="https://crates.io/crates/tracing-logfmt"><code>tracing-logfmt</code></a> provides a layer that formats events and spans into the logfmt format.</li>
<li><a href="https://crates.io/crates/reqwest-tracing"><code>reqwest-tracing</code></a> provides a middleware to trace <a href="https://crates.io/crates/reqwest"><code>reqwest</code></a> HTTP requests.</li>
<li><a href="https://crates.io/crates/tracing-cloudwatch"><code>tracing-cloudwatch</code></a> provides a layer that sends events to AWS CloudWatch Logs.</li>
<li><a href="https://crates.io/crates/clippy-tracing"><code>clippy-tracing</code></a> provides a tool to add, remove and check for <code>tracing::instrument</code>.</li>
<li><a href="https://crates.io/crates/json-subscriber"><code>json-subscriber</code></a> provides a subscriber for emitting JSON logs. The output can be customized much more than with <a href="https://crates.io/crates/tracing-subscriber"><code>tracing-subscriber</code></a>s JSON output.</li>
</ul>
<p>If youre the maintainer of a <code>tracing</code> ecosystem crate not listed above,
please let us know! Wed love to add your project to the list!</p>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: Some of these ecosystem crates are currently
unreleased and/or in earlier stages of development. They may be less stable
than <code>tracing</code> and <code>tracing-core</code>.
</pre>
<h3 id="crate-feature-flags"><a class="doc-anchor" href="#crate-feature-flags">§</a>Crate Feature Flags</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>A set of features controlling the <a href="level_filters/index.html#compile-time-filters" title="mod tracing::level_filters">static verbosity level</a>.</p>
</li>
<li>
<p><code>log</code>: causes trace instrumentation points to emit <a href="https://docs.rs/log/0.4.6/log/"><code>log</code></a> records as well
as trace events, if a default <code>tracing</code> subscriber has not been set. This
is intended for use in libraries whose users may be using either <code>tracing</code>
or <code>log</code>.</p>
</li>
<li>
<p><code>log-always</code>: Emit <code>log</code> records from all <code>tracing</code> spans and events, even
if a <code>tracing</code> subscriber has been set. This should be set only by
applications which intend to collect traces and logs separately; if an
adapter is used to convert <code>log</code> records into <code>tracing</code> events, this will
cause duplicate events to occur.</p>
</li>
<li>
<p><code>attributes</code>: Includes support for the <code>#[instrument]</code> attribute.
This is on by default, but does bring in the <code>syn</code> crate as a dependency,
which may add to the compile time of crates that do not already use it.</p>
</li>
<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 = { version = &quot;0.1.38&quot;, default-features = false }</code></pre></div></li>
</ul>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: <code>tracing</code>'s <code>no_std</code> support
requires <code>liballoc</code>.
</pre>
<h4 id="unstable-features"><a class="doc-anchor" href="#unstable-features">§</a>Unstable Features</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" title="mod tracing::field">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 class="doc-anchor" href="#enabling-unstable-features">§</a>Enabling Unstable Features</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=&quot;--cfg tracing_unstable&quot; 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 = [&quot;--cfg&quot;, &quot;tracing_unstable&quot;]</code></pre></div><h3 id="supported-rust-versions"><a class="doc-anchor" href="#supported-rust-versions">§</a>Supported Rust Versions</h3>
<p>Tracing is built against the latest stable release. The minimum supported
version is 1.65. 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="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="dispatcher/index.html" title="mod tracing::dispatcher">dispatcher</a></dt><dd>Dispatches trace events to <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>s.</dd><dt><a class="mod" href="event/index.html" title="mod tracing::event">event</a></dt><dd>Events represent single points in time during the execution of a program.</dd><dt><a class="mod" href="field/index.html" title="mod tracing::field">field</a></dt><dd><code>Span</code> and <code>Event</code> key-value data.</dd><dt><a class="mod" href="instrument/index.html" title="mod tracing::instrument">instrument</a></dt><dd>Attach a span to a <code>std::future::Future</code>.</dd><dt><a class="mod" href="level_filters/index.html" title="mod tracing::level_filters">level_<wbr>filters</a></dt><dd>Trace verbosity level filtering.</dd><dt><a class="mod" href="span/index.html" title="mod tracing::span">span</a></dt><dd>Spans represent periods of time in which a program was executing in a
particular context.</dd><dt><a class="mod" href="subscriber/index.html" title="mod tracing::subscriber">subscriber</a></dt><dd>Collects and records trace data.</dd></dl><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro.debug.html" title="macro tracing::debug">debug</a></dt><dd>Constructs an event at the debug level.</dd><dt><a class="macro" href="macro.debug_span.html" title="macro tracing::debug_span">debug_<wbr>span</a></dt><dd>Constructs a span at the debug level.</dd><dt><a class="macro" href="macro.enabled.html" title="macro tracing::enabled">enabled</a></dt><dd>Checks whether a span or event is <a href="trait.Subscriber.html#tymethod.enabled" title="method tracing::Subscriber::enabled">enabled</a> based on the provided <a href="struct.Metadata.html" title="struct tracing::Metadata">metadata</a>.</dd><dt><a class="macro" href="macro.error.html" title="macro tracing::error">error</a></dt><dd>Constructs an event at the error level.</dd><dt><a class="macro" href="macro.error_span.html" title="macro tracing::error_span">error_<wbr>span</a></dt><dd>Constructs a span at the error level.</dd><dt><a class="macro" href="macro.event.html" title="macro tracing::event">event</a></dt><dd>Constructs a new <code>Event</code>.</dd><dt><a class="macro" href="macro.event_enabled.html" title="macro tracing::event_enabled">event_<wbr>enabled</a></dt><dd>Tests whether an event with the specified level and target would be enabled.</dd><dt><a class="macro" href="macro.info.html" title="macro tracing::info">info</a></dt><dd>Constructs an event at the info level.</dd><dt><a class="macro" href="macro.info_span.html" title="macro tracing::info_span">info_<wbr>span</a></dt><dd>Constructs a span at the info level.</dd><dt><a class="macro" href="macro.record_all.html" title="macro tracing::record_all">record_<wbr>all</a></dt><dd>Records multiple values on a span in a single call. As with recording
individual values, all fields must be declared when the span is created.</dd><dt><a class="macro" href="macro.span.html" title="macro tracing::span">span</a></dt><dd>Constructs a new span.</dd><dt><a class="macro" href="macro.span_enabled.html" title="macro tracing::span_enabled">span_<wbr>enabled</a></dt><dd>Tests whether a span with the specified level and target would be enabled.</dd><dt><a class="macro" href="macro.trace.html" title="macro tracing::trace">trace</a></dt><dd>Constructs an event at the trace level.</dd><dt><a class="macro" href="macro.trace_span.html" title="macro tracing::trace_span">trace_<wbr>span</a></dt><dd>Constructs a span at the trace level.</dd><dt><a class="macro" href="macro.warn.html" title="macro tracing::warn">warn</a></dt><dd>Constructs an event at the warn level.</dd><dt><a class="macro" href="macro.warn_span.html" title="macro tracing::warn_span">warn_<wbr>span</a></dt><dd>Constructs a span at the warn level.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a></dt><dd><code>Dispatch</code> trace data to a <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</dd><dt><a class="struct" href="struct.Event.html" title="struct tracing::Event">Event</a></dt><dd><code>Event</code>s represent single points in time where something occurred during the
execution of a program.</dd><dt><a class="struct" href="struct.Level.html" title="struct tracing::Level">Level</a></dt><dd>Describes the level of verbosity of a span or event.</dd><dt><a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a></dt><dd>Metadata describing a <a href="../tracing_core/span/index.html" title="mod tracing_core::span">span</a> or <a href="event/index.html" title="mod tracing::event">event</a>.</dd><dt><a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></dt><dd>A handle representing a span, with the capability to enter the span if it
exists.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Instrument.html" title="trait tracing::Instrument">Instrument</a></dt><dd>Attaches spans to a <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>std::future::Future</code></a>.</dd><dt><a class="trait" href="trait.Subscriber.html" title="trait tracing::Subscriber">Subscriber</a></dt><dd>Trait representing the functions required to collect trace data.</dd><dt><a class="trait" href="trait.Value.html" title="trait tracing::Value">Value</a></dt><dd>A field value of an erased type.</dd></dl><h2 id="attributes" class="section-header">Attribute Macros<a href="#attributes" class="anchor">§</a></h2><dl class="item-table"><dt><a class="attr" href="attr.instrument.html" title="attr tracing::instrument">instrument</a></dt><dd>Instruments a function to create and enter a <code>tracing</code> <a href="https://docs.rs/tracing/latest/tracing/span/index.html">span</a> every time
the function is called.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1,3 @@
<!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="Attach a span to a `std::future::Future`."><title>tracing::instrument - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module instrument</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module instrument</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>instrument</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/instrument.rs.html#1-429">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Attach a span to a <code>std::future::Future</code>.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a></dt><dd>A <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> that has been instrumented with a <code>tracing</code> <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a>.</dd><dt><a class="struct" href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">With<wbr>Dispatch</a></dt><dd>A <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> that has been instrumented with a <code>tracing</code> <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Instrument.html" title="trait tracing::instrument::Instrument">Instrument</a></dt><dd>Attaches spans to a <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>std::future::Future</code></a>.</dd><dt><a class="trait" href="trait.WithSubscriber.html" title="trait tracing::instrument::WithSubscriber">With<wbr>Subscriber</a></dt><dd>Extension trait allowing futures to be instrumented with
a <code>tracing</code> <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Instrumented","WithDispatch"],"trait":["Instrument","WithSubscriber"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,69 @@
<!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="Attaches spans to a `std::future::Future`."><title>Instrument in tracing::instrument - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Instrument</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Instrument</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.in_current_span" title="in_current_span">in_current_span</a></li><li><a href="#method.instrument" title="instrument">instrument</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>instrument</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">instrument</a></div><h1>Trait <span class="trait">Instrument</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/instrument.rs.html#20-131">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Instrument: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
// Provided methods
fn <a href="#method.instrument" class="fn">instrument</a>(self, span: <a class="struct" href="../struct.Span.html" title="struct tracing::Span">Span</a>) -&gt; <a class="struct" href="struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a> { ... }
<span class="item-spacer"></span> fn <a href="#method.in_current_span" class="fn">in_current_span</a>(self) -&gt; <a class="struct" href="struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Attaches spans to a <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>std::future::Future</code></a>.</p>
<p>Extension trait allowing futures to be
instrumented with a <code>tracing</code> <a href="../struct.Span.html" title="struct tracing::Span">span</a>.</p>
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method"><a class="src rightside" href="../../src/tracing/instrument.rs.html#86-91">Source</a><h4 class="code-header">fn <a href="#method.instrument" class="fn">instrument</a>(self, span: <a class="struct" href="../struct.Span.html" title="struct tracing::Span">Span</a>) -&gt; <a class="struct" href="struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a></h4></section></summary><div class="docblock"><p>Instruments this type with the provided <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a>, returning an
<code>Instrumented</code> wrapper.</p>
<p>The attached <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a> will be <a href="../struct.Span.html#method.enter" title="method tracing::Span::enter">entered</a> every time the instrumented
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> is polled or <a href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop"><code>Drop</code></a>ped.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<p>Instrumenting a future:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">let </span>my_future = <span class="kw">async </span>{
<span class="comment">// ...
</span>};
my_future
.instrument(<span class="macro">tracing::info_span!</span>(<span class="string">"my_future"</span>))
.<span class="kw">await</span></code></pre></div>
<p>The <a href="../struct.Span.html#method.or_current" title="method tracing::Span::or_current"><code>Span::or_current</code></a> combinator can be used in combination with
<code>instrument</code> to ensure that the <a href="../struct.Span.html#method.current" title="associated function tracing::Span::current">current span</a> is attached to the
future if the span passed to <code>instrument</code> is <a href="../struct.Span.html#method.is_disabled" title="method tracing::Span::is_disabled">disabled</a>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">let </span>my_future = <span class="kw">async </span>{
<span class="comment">// ...
</span>};
<span class="kw">let </span>outer_span = <span class="macro">tracing::info_span!</span>(<span class="string">"outer"</span>).entered();
<span class="comment">// If the "my_future" span is enabled, then the spawned task will
// be within both "my_future" *and* "outer", since "outer" is
// "my_future"'s parent. However, if "my_future" is disabled,
// the spawned task will *not* be in any span.
</span>tokio::spawn(
my_future
.instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">"my_future"</span>))
);
<span class="comment">// Using `Span::or_current` ensures the spawned task is instrumented
// with the current span, if the new span passed to `instrument` is
// not enabled. This means that if the "my_future" span is disabled,
// the spawned task will still be instrumented with the "outer" span:
</span>tokio::spawn(
my_future
.instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">"my_future"</span>).or_current())
);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method"><a class="src rightside" href="../../src/tracing/instrument.rs.html#128-130">Source</a><h4 class="code-header">fn <a href="#method.in_current_span" class="fn">in_current_span</a>(self) -&gt; <a class="struct" href="struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a></h4></section></summary><div class="docblock"><p>Instruments this type with the <a href="../struct.Span.html#method.current" title="associated function tracing::Span::current">current</a> <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a>, returning an
<code>Instrumented</code> wrapper.</p>
<p>The attached <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a> will be <a href="../struct.Span.html#method.enter" title="method tracing::Span::enter">entered</a> every time the instrumented
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> is polled or <a href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop"><code>Drop</code></a>ped.</p>
<p>This can be used to propagate the current span when spawning a new future.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">let </span>span = <span class="macro">tracing::info_span!</span>(<span class="string">"my_span"</span>);
<span class="kw">let </span>_enter = span.enter();
<span class="comment">// ...
</span><span class="kw">let </span>future = <span class="kw">async </span>{
<span class="macro">tracing::debug!</span>(<span class="string">"this event will occur inside `my_span`"</span>);
<span class="comment">// ...
</span>};
tokio::spawn(future.in_current_span());</code></pre></div></div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Instrument-for-T" class="impl"><a class="src rightside" href="../../src/tracing/instrument.rs.html#325">Source</a><a href="#impl-Instrument-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="../trait.Instrument.html" title="trait tracing::Instrument">Instrument</a> for T</h3></section></div><script src="../../trait.impl/tracing/instrument/trait.Instrument.js" async></script><script type="text/json" id="notable-traits-data">{"Instrumented<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Instrumented.html\" title=\"struct tracing::instrument::Instrumented\">Instrumented</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Instrumented.html\" title=\"struct tracing::instrument::Instrumented\">Instrumented</a>&lt;T&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,58 @@
<!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="Extension trait allowing futures to be instrumented with a `tracing` `Subscriber`."><title>WithSubscriber in tracing::instrument - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">WithSubscriber</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">With<wbr>Subscriber</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.with_current_subscriber" title="with_current_subscriber">with_current_subscriber</a></li><li><a href="#method.with_subscriber" title="with_subscriber">with_subscriber</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>instrument</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">instrument</a></div><h1>Trait <span class="trait">With<wbr>Subscriber</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/instrument.rs.html#136-234">Source</a> </span></div><pre class="rust item-decl"><code>pub trait WithSubscriber: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
// Provided methods
fn <a href="#method.with_subscriber" class="fn">with_subscriber</a>&lt;S&gt;(self, subscriber: S) -&gt; <a class="struct" href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="WithDispatch&lt;Self&gt;"></a>
<span class="where">where S: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>&gt;</span> { ... }
<span class="item-spacer"></span> fn <a href="#method.with_current_subscriber" class="fn">with_current_subscriber</a>(self) -&gt; <a class="struct" href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="WithDispatch&lt;Self&gt;"></a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extension trait allowing futures to be instrumented with
a <code>tracing</code> <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</p>
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.with_subscriber" class="method"><a class="src rightside" href="../../src/tracing/instrument.rs.html#176-184">Source</a><h4 class="code-header">fn <a href="#method.with_subscriber" class="fn">with_subscriber</a>&lt;S&gt;(self, subscriber: S) -&gt; <a class="struct" href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="WithDispatch&lt;Self&gt;"></a><div class="where">where
S: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>&gt;,</div></h4></section></summary><div class="docblock"><p>Attaches the provided <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> to this type, returning a
<a href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch"><code>WithDispatch</code></a> wrapper.</p>
<p>The attached <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> will be set as the <a href="../dispatcher/index.html#setting-the-default-subscriber" title="mod tracing::dispatcher">default</a> when the returned
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> is polled.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::instrument::WithSubscriber;
<span class="comment">// Set the default `Subscriber`
</span><span class="kw">let </span>_default = tracing::subscriber::set_default(MySubscriber::default());
<span class="macro">tracing::info!</span>(<span class="string">"this event will be recorded by the default `Subscriber`"</span>);
<span class="comment">// Create a different `Subscriber` and attach it to a future.
</span><span class="kw">let </span>other_subscriber = MyOtherSubscriber::default();
<span class="kw">let </span>future = <span class="kw">async </span>{
<span class="macro">tracing::info!</span>(<span class="string">"this event will be recorded by the other `Subscriber`"</span>);
<span class="comment">// ...
</span>};
future
<span class="comment">// Attach the other `Subscriber` to the future before awaiting it
</span>.with_subscriber(other_subscriber)
.<span class="kw">await</span>;
<span class="comment">// Once the future has completed, we return to the default `Subscriber`.
</span><span class="macro">tracing::info!</span>(<span class="string">"this event will be recorded by the default `Subscriber`"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method"><a class="src rightside" href="../../src/tracing/instrument.rs.html#228-233">Source</a><h4 class="code-header">fn <a href="#method.with_current_subscriber" class="fn">with_current_subscriber</a>(self) -&gt; <a class="struct" href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="WithDispatch&lt;Self&gt;"></a></h4></section></summary><div class="docblock"><p>Attaches the current <a href="../dispatcher/index.html#setting-the-default-subscriber" title="mod tracing::dispatcher">default</a> <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> to this type, returning a
<a href="struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch"><code>WithDispatch</code></a> wrapper.</p>
<p>The attached <code>Subscriber</code> will be set as the <a href="../dispatcher/index.html#setting-the-default-subscriber" title="mod tracing::dispatcher">default</a> when the returned
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> is polled.</p>
<p>This can be used to propagate the current dispatcher context when
spawning a new future that may run on a different thread.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::instrument::WithSubscriber;
<span class="comment">// Using `set_default` (rather than `set_global_default`) sets the
// default `Subscriber` for *this* thread only.
</span><span class="kw">let </span>_default = tracing::subscriber::set_default(MySubscriber::default());
<span class="kw">let </span>future = <span class="kw">async </span>{
<span class="comment">// ...
</span>};
<span class="comment">// If a multi-threaded async runtime is in use, this spawned task may
// run on a different thread, in a different default `Subscriber`'s context.
</span>tokio::spawn(future);
<span class="comment">// However, calling `with_current_subscriber` on the future before
// spawning it, ensures that the current thread's default `Subscriber` is
// propagated to the spawned task, regardless of where it executes:
</span>tokio::spawn(future.with_current_subscriber());</code></pre></div></div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-WithSubscriber-for-T" class="impl"><a class="src rightside" href="../../src/tracing/instrument.rs.html#393">Source</a><a href="#impl-WithSubscriber-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.WithSubscriber.html" title="trait tracing::instrument::WithSubscriber">WithSubscriber</a> for T</h3></section></div><script src="../../trait.impl/tracing/instrument/trait.WithSubscriber.js" async></script><script type="text/json" id="notable-traits-data">{"WithDispatch<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.WithDispatch.html\" title=\"struct tracing::instrument::WithDispatch\">WithDispatch</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.WithDispatch.html\" title=\"struct tracing::instrument::WithDispatch\">WithDispatch</a>&lt;T&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>"}</script></section></div></main></body></html>

View File

@@ -0,0 +1,8 @@
<!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="The statically configured maximum trace level."><title>STATIC_MAX_LEVEL in tracing::level_filters - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">STATIC_MAX_LEVEL</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>level_<wbr>filters</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">level_filters</a></div><h1>Constant <span class="constant">STATIC_<wbr>MAX_<wbr>LEVEL</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/level_filters.rs.html#66">Source</a> </span></div><pre class="rust item-decl"><code>pub const STATIC_MAX_LEVEL: <a class="struct" href="struct.LevelFilter.html" title="struct tracing::level_filters::LevelFilter">LevelFilter</a>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The statically configured maximum trace level.</p>
<p>See the <a href="index.html#compile-time-filters" title="mod tracing::level_filters">module-level documentation</a> for information on how to configure
this.</p>
<p>This value is checked by the <code>event!</code> and <code>span!</code> macros. Code that
manually constructs events or spans via the <code>Event::record</code> function or
<code>Span</code> constructors should compare the level against this value to
determine if those spans or events are enabled.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,40 @@
<!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="Trace verbosity level filtering."><title>tracing::level_filters - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module level_filters</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module level_<wbr>filters</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#compile-time-filters" title="Compile time filters">Compile time filters</a><ul><li><a href="#notes" title="Notes">Notes</a></li></ul></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#constants" title="Constants">Constants</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>level_<wbr>filters</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/level_filters.rs.html#1-113">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trace verbosity level filtering.</p>
<h2 id="compile-time-filters"><a class="doc-anchor" href="#compile-time-filters">§</a>Compile time filters</h2>
<p>Trace verbosity levels can be statically disabled at compile time via Cargo
features, similar to the <a href="https://docs.rs/log/latest/log/#compile-time-filters"><code>log</code> crate</a>. Trace instrumentation at disabled
levels will be skipped and will not even be present in the resulting binary
unless the verbosity level is specified dynamically. This level is
configured separately for release and debug builds. The features are:</p>
<ul>
<li><code>max_level_off</code></li>
<li><code>max_level_error</code></li>
<li><code>max_level_warn</code></li>
<li><code>max_level_info</code></li>
<li><code>max_level_debug</code></li>
<li><code>max_level_trace</code></li>
<li><code>release_max_level_off</code></li>
<li><code>release_max_level_error</code></li>
<li><code>release_max_level_warn</code></li>
<li><code>release_max_level_info</code></li>
<li><code>release_max_level_debug</code></li>
<li><code>release_max_level_trace</code></li>
</ul>
<p>These features control the value of the <code>STATIC_MAX_LEVEL</code> constant. The
instrumentation macros macros check this value before recording an event or
constructing a span. By default, no levels are disabled.</p>
<p>For example, a crate can disable trace level instrumentation in debug builds
and trace, debug, and info level instrumentation in release builds with the
following configuration:</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
tracing = { version = &quot;0.1&quot;, features = [&quot;max_level_debug&quot;, &quot;release_max_level_warn&quot;] }</code></pre></div><h3 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h3>
<p>Please note that <code>tracing</code>s static max level features do <em>not</em> control the
<a href="https://docs.rs/log/"><code>log</code></a> records that may be emitted when <a href="https://docs.rs/tracing/latest/tracing/#emitting-log-records"><code>tracing</code>s “log” feature flag</a> is
enabled. This is to allow <code>tracing</code> to be disabled entirely at compile time
while still emitting <code>log</code> records — such as when a library using
<code>tracing</code> is used by an application using <code>log</code> that doesnt want to
generate any <code>tracing</code>-related code, but does want to collect <code>log</code> records.</p>
<p>This means that if the “log” feature is in use, some code may be generated
for <code>log</code> records emitted by disabled <code>tracing</code> events. If this is not
desirable, <code>log</code> records may be disabled separately using <a href="https://docs.rs/log/latest/log/#compile-time-filters"><code>log</code>s static
max level features</a>.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.LevelFilter.html" title="struct tracing::level_filters::LevelFilter">Level<wbr>Filter</a></dt><dd>A filter comparable to a verbosity <a href="../struct.Level.html" title="struct tracing::Level"><code>Level</code></a>.</dd><dt><a class="struct" href="struct.ParseLevelFilterError.html" title="struct tracing::level_filters::ParseLevelFilterError">Parse<wbr>Level<wbr>Filter<wbr>Error</a></dt><dd>Indicates that a string could not be parsed to a valid level.</dd></dl><h2 id="constants" class="section-header">Constants<a href="#constants" class="anchor">§</a></h2><dl class="item-table"><dt><a class="constant" href="constant.STATIC_MAX_LEVEL.html" title="constant tracing::level_filters::STATIC_MAX_LEVEL">STATIC_<wbr>MAX_<wbr>LEVEL</a></dt><dd>The statically configured maximum trace level.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"constant":["STATIC_MAX_LEVEL"],"struct":["LevelFilter","ParseLevelFilterError"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.debug.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.debug.html">macro.debug.html</a>...</p>
<script>location.replace("macro.debug.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,62 @@
<!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="Constructs an event at the debug level."><title>debug in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">debug</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">debug</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">debug</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#1609-1859">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! debug {
(name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($arg:tt)+) =&gt; { ... };
({ $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
($($k:ident).+ = $($field:tt)*) =&gt; { ... };
(?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(%$($k:ident).+ = $($field:tt)*) =&gt; { ... };
($($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(%$($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+) =&gt; { ... };
(%$($k:ident).+) =&gt; { ... };
($($k:ident).+) =&gt; { ... };
($($arg:tt)+) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs an event at the debug level.</p>
<p>This functions similarly to the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro. See <a href="index.html#using-the-macros" title="mod tracing">the top-level
documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::debug;
<span class="kw">let </span>pos = Position { x: <span class="number">3.234</span>, y: -<span class="number">1.223 </span>};
<span class="macro">debug!</span>(<span class="question-mark">?</span>pos.x, <span class="question-mark">?</span>pos.y);
<span class="macro">debug!</span>(target: <span class="string">"app_events"</span>, position = <span class="question-mark">?</span>pos, <span class="string">"New position"</span>);
<span class="macro">debug!</span>(name: <span class="string">"completed"</span>, position = <span class="question-mark">?</span>pos);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.debug_span.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.debug_span.html">macro.debug_span.html</a>...</p>
<script>location.replace("macro.debug_span.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!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="Constructs a span at the debug level."><title>debug_span in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">debug_span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">debug_<wbr>span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">debug_<wbr>span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#278-323">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! debug_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $name:expr) =&gt; { ... };
(parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $name:expr) =&gt; { ... };
(target: $target:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, $name:expr) =&gt; { ... };
($name:expr, $($field:tt)*) =&gt; { ... };
($name:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a span at the debug level.</p>
<p><a href="index.html#recording-fields" title="mod tracing">Fields</a> and <a href="index.html#configuring-attributes" title="mod tracing">attributes</a> are set using the same syntax as the <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a>
macro.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">debug_span!</span>(<span class="string">"my_span"</span>);
<span class="comment">// is equivalent to:
</span><span class="macro">span!</span>(Level::DEBUG, <span class="string">"my_span"</span>);</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">debug_span!</span>(<span class="string">"my span"</span>);
span.in_scope(|| {
<span class="comment">// do work inside the span...
</span>});</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.enabled.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.enabled.html">macro.enabled.html</a>...</p>
<script>location.replace("macro.enabled.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,71 @@
<!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="Checks whether a span or event is enabled based on the provided metadata."><title>enabled in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">enabled</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">enabled</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#usage" title="Usage">Usage</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#alternatives" title="Alternatives">Alternatives</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">enabled</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#1214-1294">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! enabled {
(kind: $kind:expr, target: $target:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(kind: $kind:expr, target: $target:expr, $lvl:expr ) =&gt; { ... };
(target: $target:expr, $lvl:expr ) =&gt; { ... };
(kind: $kind:expr, target: $target:expr, $lvl:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, $lvl:expr, $($field:tt)*) =&gt; { ... };
(kind: $kind:expr, $lvl:expr, $($field:tt)*) =&gt; { ... };
(kind: $kind:expr, $lvl:expr) =&gt; { ... };
($lvl:expr) =&gt; { ... };
($lvl:expr, $($field:tt)*) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Checks whether a span or event is <a href="trait.Subscriber.html#tymethod.enabled" title="method tracing::Subscriber::enabled">enabled</a> based on the provided <a href="struct.Metadata.html" title="struct tracing::Metadata">metadata</a>.</p>
<p>This macro is a specialized tool: it is intended to be used prior
to an expensive computation required <em>just</em> for that event, but
<em>cannot</em> be done as part of an argument to that event, such as
when multiple events are emitted (e.g., iterating over a collection
and emitting an event for each item).</p>
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
<p><a href="trait.Subscriber.html" title="trait tracing::Subscriber">Subscribers</a> can make filtering decisions based all the data included in a
span or events <a href="struct.Metadata.html" title="struct tracing::Metadata"><code>Metadata</code></a>. This means that it is possible for <code>enabled!</code>
to return a <em>false positive</em> (indicating that something would be enabled
when it actually would not be) or a <em>false negative</em> (indicating that
something would be disabled when it would actually be enabled).</p>
<p>This occurs when a subscriber is using a <em>more specific</em> filter than the
metadata provided to the <code>enabled!</code> macro. Some situations that can result
in false positives or false negatives include:</p>
<ul>
<li>If a subscriber is using a filter which may enable a span or event based
on field names, but <code>enabled!</code> is invoked without listing field names,
<code>enabled!</code> may return a false negative if a specific field name would
cause the subscriber to enable something that would otherwise be disabled.</li>
<li>If a subscriber is using a filter which enables or disables specific events by
file path and line number, a particular event may be enabled/disabled
even if an <code>enabled!</code> invocation with the same level, target, and fields
indicated otherwise.</li>
<li>The subscriber can choose to enable <em>only</em> spans or <em>only</em> events, which <code>enabled</code>
will not reflect.</li>
</ul>
<p><code>enabled!()</code> requires a <a href="struct.Level.html" title="struct tracing::Level">level</a> argument, an optional <code>target:</code>
argument, and an optional set of field names. If the fields are not provided,
they are considered to be unknown. <code>enabled!</code> attempts to match the
syntax of <code>event!()</code> as closely as possible, which can be seen in the
examples below.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>If the current subscriber is interested in recording <code>DEBUG</code>-level spans and
events in the current file and module path, this will evaluate to true:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{enabled, Level};
<span class="kw">if </span><span class="macro">enabled!</span>(Level::DEBUG) {
<span class="comment">// some expensive work...
</span>}</code></pre></div>
<p>If the current subscriber is interested in recording spans and events
in the current file and module path, with the target “my_crate”, and at the
level <code>DEBUG</code>, this will evaluate to true:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">if </span><span class="macro">enabled!</span>(target: <span class="string">"my_crate"</span>, Level::DEBUG) {
<span class="comment">// some expensive work...
</span>}</code></pre></div>
<p>If the current subscriber is interested in recording spans and events
in the current file and module path, with the target “my_crate”, at
the level <code>DEBUG</code>, and with a field named “hello”, this will evaluate
to true:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">if </span><span class="macro">enabled!</span>(target: <span class="string">"my_crate"</span>, Level::DEBUG, hello) {
<span class="comment">// some expensive work...
</span>}</code></pre></div><h2 id="alternatives"><a class="doc-anchor" href="#alternatives">§</a>Alternatives</h2>
<p><code>enabled!</code> queries subscribers with <a href="struct.Metadata.html" title="struct tracing::Metadata"><code>Metadata</code></a> where
<a href="struct.Metadata.html#method.is_event" title="method tracing::Metadata::is_event"><code>is_event</code></a> and <a href="struct.Metadata.html#method.is_span" title="method tracing::Metadata::is_span"><code>is_span</code></a> both return <code>false</code>. Alternatively,
use <a href="macro.event_enabled.html" title="macro tracing::event_enabled"><code>event_enabled!</code></a> or <a href="macro.span_enabled.html" title="macro tracing::span_enabled"><code>span_enabled!</code></a> to ensure one of these
returns true.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.error.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.error.html">macro.error.html</a>...</p>
<script>location.replace("macro.error.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,63 @@
<!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="Constructs an event at the error level."><title>error in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">error</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">error</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">error</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#2452-2702">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! error {
(name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($arg:tt)+) =&gt; { ... };
({ $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
($($k:ident).+ = $($field:tt)*) =&gt; { ... };
(?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(%$($k:ident).+ = $($field:tt)*) =&gt; { ... };
($($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(%$($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+) =&gt; { ... };
(%$($k:ident).+) =&gt; { ... };
($($k:ident).+) =&gt; { ... };
($($arg:tt)+) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs an event at the error level.</p>
<p>This functions similarly to the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro. See <a href="index.html#using-the-macros" title="mod tracing">the top-level
documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::error;
<span class="kw">let </span>(err_info, port) = (<span class="string">"No connection"</span>, <span class="number">22</span>);
<span class="macro">error!</span>(port, error = %err_info);
<span class="macro">error!</span>(target: <span class="string">"app_events"</span>, <span class="string">"App Error: {}"</span>, err_info);
<span class="macro">error!</span>({ info = err_info }, <span class="string">"error on port: {}"</span>, port);
<span class="macro">error!</span>(name: <span class="string">"invalid_input"</span>, <span class="string">"Invalid input: {}"</span>, err_info);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.error_span.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.error_span.html">macro.error_span.html</a>...</p>
<script>location.replace("macro.error_span.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!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="Constructs a span at the error level."><title>error_span in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">error_span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">error_<wbr>span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">error_<wbr>span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#520-565">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! error_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $name:expr) =&gt; { ... };
(parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $name:expr) =&gt; { ... };
(target: $target:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, $name:expr) =&gt; { ... };
($name:expr, $($field:tt)*) =&gt; { ... };
($name:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a span at the error level.</p>
<p><a href="index.html#recording-fields" title="mod tracing">Fields</a> and <a href="index.html#configuring-attributes" title="mod tracing">attributes</a> are set using the same syntax as the <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a>
macro.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">error_span!</span>(<span class="string">"my_span"</span>);
<span class="comment">// is equivalent to:
</span><span class="macro">span!</span>(Level::ERROR, <span class="string">"my_span"</span>);</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">error_span!</span>(<span class="string">"my span"</span>);
span.in_scope(|| {
<span class="comment">// do work inside the span...
</span>});</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.event.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.event.html">macro.event.html</a>...</p>
<script>location.replace("macro.event.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<!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="Constructs a new `Event`."><title>event in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">event</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">event</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">event</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#615-1053">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! event {
(name: $name:expr, target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $lvl:expr, $($arg:tt)+) =&gt; { ... };
(name: $name:expr, target: $target:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $lvl:expr, $($arg:tt)+) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $lvl:expr, $($arg:tt)+) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $lvl:expr, $($arg:tt)+) =&gt; { ... };
(name: $name:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(name: $name:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) =&gt; { ... };
(name: $name:expr, $lvl:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, $lvl:expr, { $($fields:tt)* } ) =&gt; { ... };
(target: $target:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, $lvl:expr, $($k:ident).+ = $($fields:tt)* ) =&gt; { ... };
(target: $target:expr, $lvl:expr, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, ?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, %$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, $($arg:tt)+ ) =&gt; { ... };
( $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
( $lvl:expr, { $($fields:tt)* }, $($arg:tt)+ ) =&gt; { ... };
($lvl:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
($lvl:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
($lvl:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
($lvl:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
($lvl:expr, ?$($k:ident).+) =&gt; { ... };
($lvl:expr, %$($k:ident).+) =&gt; { ... };
($lvl:expr, $($k:ident).+) =&gt; { ... };
( $lvl:expr, $($arg:tt)+ ) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a new <code>Event</code>.</p>
<p>The event macro is invoked with a <code>Level</code> and up to 32 key-value fields.
Optionally, a format string and arguments may follow the fields; this will
be used to construct an implicit field named “message”.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{event, Level};
<span class="kw">let </span>data = (<span class="number">42</span>, <span class="string">"forty-two"</span>);
<span class="kw">let </span>private_data = <span class="string">"private"</span>;
<span class="kw">let </span>error = <span class="string">"a bad error"</span>;
<span class="macro">event!</span>(Level::ERROR, %error, <span class="string">"Received error"</span>);
<span class="macro">event!</span>(
target: <span class="string">"app_events"</span>,
Level::WARN,
private_data,
<span class="question-mark">?</span>data,
<span class="string">"App warning: {}"</span>,
error
);
<span class="macro">event!</span>(name: <span class="string">"answer"</span>, Level::INFO, the_answer = data.<span class="number">0</span>);
<span class="macro">event!</span>(Level::INFO, the_answer = data.<span class="number">0</span>);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.event_enabled.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.event_enabled.html">macro.event_enabled.html</a>...</p>
<script>location.replace("macro.event_enabled.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!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="Tests whether an event with the specified level and target would be enabled."><title>event_enabled in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">event_enabled</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">event_<wbr>enabled</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">event_<wbr>enabled</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#1083-1087">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! event_enabled {
($($rest:tt)*) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Tests whether an event with the specified level and target would be enabled.</p>
<p>This is similar to <a href="macro.enabled.html" title="macro tracing::enabled"><code>enabled!</code></a>, but queries the current subscriber specifically for
an event, whereas <a href="macro.enabled.html" title="macro tracing::enabled"><code>enabled!</code></a> queries for an event <em>or</em> span.</p>
<p>See the documentation for [<code>enabled!]</code> for more details on using this macro.
See also <a href="macro.span_enabled.html" title="macro tracing::span_enabled"><code>span_enabled!</code></a>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">if </span><span class="macro">event_enabled!</span>(target: <span class="string">"my_crate"</span>, Level::DEBUG) {
<span class="comment">// some expensive work...
</span>}
<span class="comment">// simpler
</span><span class="kw">if </span><span class="macro">event_enabled!</span>(Level::DEBUG) {
<span class="comment">// some expensive work...
</span>}
<span class="comment">// with fields
</span><span class="kw">if </span><span class="macro">event_enabled!</span>(Level::DEBUG, foo_field) {
<span class="comment">// some expensive work...
</span>}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.info.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.info.html">macro.info.html</a>...</p>
<script>location.replace("macro.info.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,69 @@
<!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="Constructs an event at the info level."><title>info in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">info</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">info</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">info</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#1896-2146">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! info {
(name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($arg:tt)+) =&gt; { ... };
({ $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
($($k:ident).+ = $($field:tt)*) =&gt; { ... };
(?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(%$($k:ident).+ = $($field:tt)*) =&gt; { ... };
($($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(%$($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+) =&gt; { ... };
(%$($k:ident).+) =&gt; { ... };
($($k:ident).+) =&gt; { ... };
($($arg:tt)+) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs an event at the info level.</p>
<p>This functions similarly to the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro. See <a href="index.html#using-the-macros" title="mod tracing">the top-level
documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::info;
<span class="kw">use </span>tracing::field;
<span class="kw">let </span>addr = Ipv4Addr::new(<span class="number">127</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">1</span>);
<span class="kw">let </span>conn = Connection { port: <span class="number">40</span>, speed: <span class="number">3.20 </span>};
<span class="macro">info!</span>(conn.port, <span class="string">"connected to {:?}"</span>, addr);
<span class="macro">info!</span>(
target: <span class="string">"connection_events"</span>,
ip = <span class="question-mark">?</span>addr,
conn.port,
<span class="question-mark">?</span>conn.speed,
);
<span class="macro">info!</span>(name: <span class="string">"completed"</span>, <span class="string">"completed connection to {:?}"</span>, addr);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.info_span.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.info_span.html">macro.info_span.html</a>...</p>
<script>location.replace("macro.info_span.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!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="Constructs a span at the info level."><title>info_span in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">info_span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">info_<wbr>span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">info_<wbr>span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#359-404">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! info_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $name:expr) =&gt; { ... };
(parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $name:expr) =&gt; { ... };
(target: $target:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, $name:expr) =&gt; { ... };
($name:expr, $($field:tt)*) =&gt; { ... };
($name:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a span at the info level.</p>
<p><a href="index.html#recording-fields" title="mod tracing">Fields</a> and <a href="index.html#configuring-attributes" title="mod tracing">attributes</a> are set using the same syntax as the <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a>
macro.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">info_span!</span>(<span class="string">"my_span"</span>);
<span class="comment">// is equivalent to:
</span><span class="macro">span!</span>(Level::INFO, <span class="string">"my_span"</span>);</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"my span"</span>);
span.in_scope(|| {
<span class="comment">// do work inside the span...
</span>});</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.record_all.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.record_all.html">macro.record_all.html</a>...</p>
<script>location.replace("macro.record_all.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!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="Records multiple values on a span in a single call. As with recording individual values, all fields must be declared when the span is created."><title>record_all in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">record_all</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">record_<wbr>all</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">record_<wbr>all</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#152-161">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! record_all {
($span:expr, $($fields:tt)*) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Records multiple values on a span in a single call. As with recording
individual values, all fields must be declared when the span is created.</p>
<p>This macro supports two optional sigils:</p>
<ul>
<li><code>%</code> uses the Display implementation.</li>
<li><code>?</code> uses the Debug implementation.</li>
</ul>
<p>For more details, see the <a href="tracing/#recording-fields">top-level documentation</a>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"my span"</span>, field1 = field::Empty, field2 = field::Empty, field3 = field::Empty).entered();
<span class="macro">record_all!</span>(span, field1 = <span class="question-mark">?</span><span class="string">"1"</span>, field2 = %<span class="string">"2"</span>, field3 = <span class="number">3</span>);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.span.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.span.html">macro.span.html</a>...</p>
<script>location.replace("macro.span.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,20 @@
<!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="Constructs a new span."><title>span in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#20-131">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! span {
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr, $($fields:tt)*) =&gt; { ... };
(target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $lvl:expr, $name:expr) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, $name:expr, $($fields:tt)*) =&gt; { ... };
(parent: $parent:expr, $lvl:expr, $name:expr) =&gt; { ... };
(target: $target:expr, $lvl:expr, $name:expr, $($fields:tt)*) =&gt; { ... };
(target: $target:expr, $lvl:expr, $name:expr) =&gt; { ... };
($lvl:expr, $name:expr, $($fields:tt)*) =&gt; { ... };
($lvl:expr, $name:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a new span.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Creating a new span:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my span"</span>);
<span class="kw">let </span>_enter = span.enter();
<span class="comment">// do work inside the span...</span></code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.span_enabled.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.span_enabled.html">macro.span_enabled.html</a>...</p>
<script>location.replace("macro.span_enabled.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,19 @@
<!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="Tests whether a span with the specified level and target would be enabled."><title>span_enabled in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">span_enabled</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">span_<wbr>enabled</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">span_<wbr>enabled</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#1117-1121">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! span_enabled {
($($rest:tt)*) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Tests whether a span with the specified level and target would be enabled.</p>
<p>This is similar to <a href="macro.enabled.html" title="macro tracing::enabled"><code>enabled!</code></a>, but queries the current subscriber specifically for
an event, whereas <a href="macro.enabled.html" title="macro tracing::enabled"><code>enabled!</code></a> queries for an event <em>or</em> span.</p>
<p>See the documentation for [<code>enabled!]</code> for more details on using this macro.
See also <a href="macro.span_enabled.html" title="macro tracing::span_enabled"><code>span_enabled!</code></a>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">if </span><span class="macro">span_enabled!</span>(target: <span class="string">"my_crate"</span>, Level::DEBUG) {
<span class="comment">// some expensive work...
</span>}
<span class="comment">// simpler
</span><span class="kw">if </span><span class="macro">span_enabled!</span>(Level::DEBUG) {
<span class="comment">// some expensive work...
</span>}
<span class="comment">// with fields
</span><span class="kw">if </span><span class="macro">span_enabled!</span>(Level::DEBUG, foo_field) {
<span class="comment">// some expensive work...
</span>}</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.trace.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.trace.html">macro.trace.html</a>...</p>
<script>location.replace("macro.trace.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,68 @@
<!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="Constructs an event at the trace level."><title>trace in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">trace</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">trace</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">trace</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#1333-1583">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! trace {
(name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($arg:tt)+) =&gt; { ... };
({ $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
($($k:ident).+ = $($field:tt)*) =&gt; { ... };
(?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(%$($k:ident).+ = $($field:tt)*) =&gt; { ... };
($($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(%$($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+) =&gt; { ... };
(%$($k:ident).+) =&gt; { ... };
($($k:ident).+) =&gt; { ... };
($($arg:tt)+) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs an event at the trace level.</p>
<p>This functions similarly to the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro. See <a href="index.html#using-the-macros" title="mod tracing">the top-level
documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::trace;
<span class="kw">let </span>pos = Position { x: <span class="number">3.234</span>, y: -<span class="number">1.223 </span>};
<span class="kw">let </span>origin_dist = pos.dist(Position::ORIGIN);
<span class="macro">trace!</span>(position = <span class="question-mark">?</span>pos, <span class="question-mark">?</span>origin_dist);
<span class="macro">trace!</span>(
target: <span class="string">"app_events"</span>,
position = <span class="question-mark">?</span>pos,
<span class="string">"x is {} and y is {}"</span>,
<span class="kw">if </span>pos.x &gt;= <span class="number">0.0 </span>{ <span class="string">"positive" </span>} <span class="kw">else </span>{ <span class="string">"negative" </span>},
<span class="kw">if </span>pos.y &gt;= <span class="number">0.0 </span>{ <span class="string">"positive" </span>} <span class="kw">else </span>{ <span class="string">"negative" </span>}
);
<span class="macro">trace!</span>(name: <span class="string">"completed"</span>, position = <span class="question-mark">?</span>pos);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.trace_span.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.trace_span.html">macro.trace_span.html</a>...</p>
<script>location.replace("macro.trace_span.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!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="Constructs a span at the trace level."><title>trace_span in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">trace_span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">trace_<wbr>span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">trace_<wbr>span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#197-242">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! trace_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $name:expr) =&gt; { ... };
(parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $name:expr) =&gt; { ... };
(target: $target:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, $name:expr) =&gt; { ... };
($name:expr, $($field:tt)*) =&gt; { ... };
($name:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a span at the trace level.</p>
<p><a href="index.html#recording-fields" title="mod tracing">Fields</a> and <a href="index.html#configuring-attributes" title="mod tracing">attributes</a> are set using the same syntax as the <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a>
macro.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">trace_span!</span>(<span class="string">"my_span"</span>);
<span class="comment">// is equivalent to:
</span><span class="macro">span!</span>(Level::TRACE, <span class="string">"my_span"</span>);</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">trace_span!</span>(<span class="string">"my span"</span>);
span.in_scope(|| {
<span class="comment">// do work inside the span...
</span>});</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.warn.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.warn.html">macro.warn.html</a>...</p>
<script>location.replace("macro.warn.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<!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="Constructs an event at the warn level."><title>warn in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">warn</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">warn</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">warn</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#2176-2426">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! warn {
(name: $name:expr, target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, parent: $parent:expr, $($arg:tt)+ ) =&gt; { ... };
(name: $name:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(name: $name:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(name: $name:expr, $($arg:tt)+ ) =&gt; { ... };
(target: $target:expr, { $($field:tt)* }, $($arg:tt)* ) =&gt; { ... };
(target: $target:expr, $($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, ?$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, %$($k:ident).+ $($field:tt)* ) =&gt; { ... };
(target: $target:expr, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, { $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, ?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, %$($k:ident).+, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $($arg:tt)+) =&gt; { ... };
({ $($field:tt)+ }, $($arg:tt)+ ) =&gt; { ... };
($($k:ident).+ = $($field:tt)*) =&gt; { ... };
(?$($k:ident).+ = $($field:tt)*) =&gt; { ... };
(%$($k:ident).+ = $($field:tt)*) =&gt; { ... };
($($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+, $($field:tt)*) =&gt; { ... };
(%$($k:ident).+, $($field:tt)*) =&gt; { ... };
(?$($k:ident).+) =&gt; { ... };
(%$($k:ident).+) =&gt; { ... };
($($k:ident).+) =&gt; { ... };
($($arg:tt)+) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs an event at the warn level.</p>
<p>This functions similarly to the <a href="macro.event.html" title="macro tracing::event"><code>event!</code></a> macro. See <a href="index.html#using-the-macros" title="mod tracing">the top-level
documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::warn;
<span class="kw">let </span>warn_description = <span class="string">"Invalid Input"</span>;
<span class="kw">let </span>input = <span class="kw-2">&amp;</span>[<span class="number">0x27</span>, <span class="number">0x45</span>];
<span class="macro">warn!</span>(<span class="question-mark">?</span>input, warning = warn_description);
<span class="macro">warn!</span>(
target: <span class="string">"input_events"</span>,
warning = warn_description,
<span class="string">"Received warning for input: {:?}"</span>, input,
);
<span class="macro">warn!</span>(name: <span class="string">"invalid"</span>, <span class="question-mark">?</span>input);</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.warn_span.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.warn_span.html">macro.warn_span.html</a>...</p>
<script>location.replace("macro.warn_span.html" + location.search + location.hash);</script>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!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="Constructs a span at the warn level."><title>warn_span in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">warn_span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">warn_<wbr>span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Macro <span class="macro">warn_<wbr>span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/macros.rs.html#440-485">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! warn_span {
(target: $target:expr, parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, parent: $parent:expr, $name:expr) =&gt; { ... };
(parent: $parent:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(parent: $parent:expr, $name:expr) =&gt; { ... };
(target: $target:expr, $name:expr, $($field:tt)*) =&gt; { ... };
(target: $target:expr, $name:expr) =&gt; { ... };
($name:expr, $($field:tt)*) =&gt; { ... };
($name:expr) =&gt; { ... };
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Constructs a span at the warn level.</p>
<p><a href="index.html#recording-fields" title="mod tracing">Fields</a> and <a href="index.html#configuring-attributes" title="mod tracing">attributes</a> are set using the same syntax as the <a href="macro.span.html" title="macro tracing::span"><code>span!</code></a>
macro.</p>
<p>See <a href="index.html#using-the-macros" title="mod tracing">the top-level documentation</a> for details on the syntax accepted by
this macro.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="macro">warn_span!</span>(<span class="string">"my_span"</span>);
<span class="comment">// is equivalent to:
</span><span class="macro">span!</span>(Level::WARN, <span class="string">"my_span"</span>);</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::warn_span;
<span class="kw">let </span>span = <span class="macro">warn_span!</span>(<span class="string">"my span"</span>);
span.in_scope(|| {
<span class="comment">// do work inside the span...
</span>});</code></pre></div></div></details></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"attr":["instrument"],"macro":["debug","debug_span","enabled","error","error_span","event","event_enabled","info","info_span","record_all","span","span_enabled","trace","trace_span","warn","warn_span"],"mod":["dispatcher","event","field","instrument","level_filters","span","subscriber"],"struct":["Dispatch","Event","Level","Metadata","Span"],"trait":["Instrument","Subscriber","Value"]};

View File

@@ -0,0 +1,238 @@
<!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="Spans represent periods of time in which a program was executing in a particular context."><title>tracing::span - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module span</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module span</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#creating-spans" title="Creating Spans">Creating Spans</a><ul><li><a href="#recording-span-creation" title="Recording Span Creation">Recording Span Creation</a></li></ul></li><li><a href="#the-span-lifecycle" title="The Span Lifecycle">The Span Lifecycle</a><ul><li><a href="#entering-a-span" title="Entering a Span">Entering a Span</a></li><li><a href="#span-relationships" title="Span Relationships">Span Relationships</a></li><li><a href="#closing-spans" title="Closing Spans">Closing Spans</a></li></ul></li><li><a href="#when-to-use-spans" title="When to use spans">When to use spans</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>span</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/span.rs.html#1-1615">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spans represent periods of time in which a program was executing in a
particular context.</p>
<p>A span consists of <a href="../field/index.html" title="mod tracing::field">fields</a>, user-defined key-value pairs of arbitrary data
that describe the context the span represents, and a set of fixed attributes
that describe all <code>tracing</code> spans and events. Attributes describing spans
include:</p>
<ul>
<li>An <a href="struct.Id.html" title="struct tracing::span::Id"><code>Id</code></a> assigned by the subscriber that uniquely identifies it in relation
to other spans.</li>
<li>The spans <a href="#span-relationships">parent</a> in the trace tree.</li>
<li><a href="../struct.Metadata.html" title="struct tracing::Metadata">Metadata</a> that describes static characteristics of all spans
originating from that callsite, such as its name, source code location,
<a href="../struct.Level.html" title="struct tracing::Level">verbosity level</a>, and the names of its fields.</li>
</ul>
<h2 id="creating-spans"><a class="doc-anchor" href="#creating-spans">§</a>Creating Spans</h2>
<p>Spans are created using the <a href="../macro.span.html" title="macro tracing::span"><code>span!</code></a> macro. This macro is invoked with the
following arguments, in order:</p>
<ul>
<li>The <a href="../struct.Metadata.html#method.target" title="method tracing::Metadata::target"><code>target</code></a> and/or <a href="#span-relationships"><code>parent</code></a> attributes, if the user wishes to
override their default values.</li>
<li>The spans <a href="../struct.Level.html" title="struct tracing::Level">verbosity level</a></li>
<li>A string literal providing the spans name.</li>
<li>Finally, zero or more arbitrary key/value fields.</li>
</ul>
<p>For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::{span, Level};
<span class="doccomment">/// Construct a new span at the `INFO` level named "my_span", with a single
/// field named answer , with the value `42`.
</span><span class="kw">let </span>my_span = <span class="macro">span!</span>(Level::INFO, <span class="string">"my_span"</span>, answer = <span class="number">42</span>);</code></pre></div>
<p>The documentation for the <a href="../macro.span.html" title="macro tracing::span"><code>span!</code></a> macro provides additional examples of
the various options that exist when creating spans.</p>
<p>The <a href="../macro.trace_span.html" title="macro tracing::trace_span"><code>trace_span!</code></a>, <a href="../macro.debug_span.html" title="macro tracing::debug_span"><code>debug_span!</code></a>, <a href="../macro.info_span.html" title="macro tracing::info_span"><code>info_span!</code></a>, <a href="../macro.warn_span.html" title="macro tracing::warn_span"><code>warn_span!</code></a>, and
<a href="../macro.error_span.html" title="macro tracing::error_span"><code>error_span!</code></a> exist as shorthand for constructing spans at various
verbosity levels.</p>
<h3 id="recording-span-creation"><a class="doc-anchor" href="#recording-span-creation">§</a>Recording Span Creation</h3>
<p>The <a href="struct.Attributes.html" title="struct tracing::span::Attributes"><code>Attributes</code></a> type contains data associated with a span, and is
provided to the <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> when a new span is created. It contains
the spans metadata, the ID of <a href="#span-relationships">the spans parent</a> if one was
explicitly set, and any fields whose values were recorded when the span was
constructed. The subscriber, which is responsible for recording <code>tracing</code>
data, can then store or record these values.</p>
<h2 id="the-span-lifecycle"><a class="doc-anchor" href="#the-span-lifecycle">§</a>The Span Lifecycle</h2><h3 id="entering-a-span"><a class="doc-anchor" href="#entering-a-span">§</a>Entering a Span</h3>
<p>A thread of execution is said to <em>enter</em> a span when it begins executing,
and <em>exit</em> the span when it switches to another context. Spans may be
entered through the <a href="../struct.Span.html#method.enter" title="method tracing::Span::enter"><code>enter</code></a>, <a href="../struct.Span.html#method.entered" title="method tracing::Span::entered"><code>entered</code></a>, and <a href="../struct.Span.html#method.in_scope" title="method tracing::Span::in_scope"><code>in_scope</code></a> methods.</p>
<p>The <a href="../struct.Span.html#method.enter" title="method tracing::Span::enter"><code>enter</code></a> method enters a span, returning a <a href="struct.Entered.html" title="struct tracing::span::Entered">guard</a> that exits the span
when dropped</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>my_var: u64 = <span class="number">5</span>;
<span class="kw">let </span>my_span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my_span"</span>, my_var);
<span class="comment">// `my_span` exists but has not been entered.
// Enter `my_span`...
</span><span class="kw">let </span>_enter = my_span.enter();
<span class="comment">// Perform some work inside of the context of `my_span`...
// Dropping the `_enter` guard will exit the span.</span></code></pre></div> <div class="example-wrap" style="display:inline-block"><pre class="compile_fail" style="white-space:normal;font:inherit;">
<strong>Warning</strong>: In asynchronous code that uses async/await syntax,
<code>Span::enter</code> may produce incorrect traces if the returned drop
guard is held across an await point. See
<a href="struct.Span.html#in-asynchronous-code">the method documentation</a>
for details.
</pre></div>
<p>The <a href="../struct.Span.html#method.entered" title="method tracing::Span::entered"><code>entered</code></a> method is analogous to <a href="../struct.Span.html#method.enter" title="method tracing::Span::enter"><code>enter</code></a>, but moves the span into
the returned guard, rather than borrowing it. This allows creating and
entering a span in a single expression:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Create a span and enter it, returning a guard:
</span><span class="kw">let </span>span = <span class="macro">span!</span>(Level::INFO, <span class="string">"my_span"</span>).entered();
<span class="comment">// We are now inside the span! Like `enter()`, the guard returned by
// `entered()` will exit the span when it is dropped...
// ...but, it can also be exited explicitly, returning the `Span`
// struct:
</span><span class="kw">let </span>span = span.exit();</code></pre></div>
<p>Finally, <a href="../struct.Span.html#method.in_scope" title="method tracing::Span::in_scope"><code>in_scope</code></a> takes a closure or function pointer and executes it
inside the span:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>my_var: u64 = <span class="number">5</span>;
<span class="kw">let </span>my_span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my_span"</span>, my_var = <span class="kw-2">&amp;</span>my_var);
my_span.in_scope(|| {
<span class="comment">// perform some work in the context of `my_span`...
</span>});
<span class="comment">// Perform some work outside of the context of `my_span`...
</span>my_span.in_scope(|| {
<span class="comment">// Perform some more work in the context of `my_span`.
</span>});</code></pre></div> <pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: Since entering a span takes <code>&self</code>, and
<code>Span</code>s are <code>Clone</code>, <code>Send</code>, and
<code>Sync</code>, it is entirely valid for multiple threads to enter the
same span concurrently.
</pre>
<h3 id="span-relationships"><a class="doc-anchor" href="#span-relationships">§</a>Span Relationships</h3>
<p>Spans form a tree structure — unless it is a root span, all spans have a
<em>parent</em>, and may have one or more <em>children</em>. When a new span is created,
the current span becomes the new spans parent. The total execution time of
a span consists of the time spent in that span and in the entire subtree
represented by its children. Thus, a parent span always lasts for at least
as long as the longest-executing span in its subtree.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// this span is considered the "root" of a new trace tree:
</span><span class="macro">span!</span>(Level::INFO, <span class="string">"root"</span>).in_scope(|| {
<span class="comment">// since we are now inside "root", this span is considered a child
// of "root":
</span><span class="macro">span!</span>(Level::DEBUG, <span class="string">"outer_child"</span>).in_scope(|| {
<span class="comment">// this span is a child of "outer_child", which is in turn a
// child of "root":
</span><span class="macro">span!</span>(Level::TRACE, <span class="string">"inner_child"</span>).in_scope(|| {
<span class="comment">// and so on...
</span>});
});
<span class="comment">// another span created here would also be a child of "root".
</span>});</code></pre></div>
<p>In addition, the parent of a span may be explicitly specified in
the <code>span!</code> macro. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Create, but do not enter, a span called "foo".
</span><span class="kw">let </span>foo = <span class="macro">span!</span>(Level::INFO, <span class="string">"foo"</span>);
<span class="comment">// Create and enter a span called "bar".
</span><span class="kw">let </span>bar = <span class="macro">span!</span>(Level::INFO, <span class="string">"bar"</span>);
<span class="kw">let </span>_enter = bar.enter();
<span class="comment">// Although we have currently entered "bar", "baz"'s parent span
// will be "foo".
</span><span class="kw">let </span>baz = <span class="macro">span!</span>(parent: <span class="kw-2">&amp;</span>foo, Level::INFO, <span class="string">"baz"</span>);</code></pre></div>
<p>A child span should typically be considered <em>part</em> of its parent. For
example, if a subscriber is recording the length of time spent in various
spans, it should generally include the time spent in a spans children as
part of that spans duration.</p>
<p>In addition to having zero or one parent, a span may also <em>follow from</em> any
number of other spans. This indicates a causal relationship between the span
and the spans that it follows from, but a follower is <em>not</em> typically
considered part of the duration of the span it follows. Unlike the parent, a
span may record that it follows from another span after it is created, using
the <a href="../struct.Span.html#method.follows_from" title="method tracing::Span::follows_from"><code>follows_from</code></a> method.</p>
<p>As an example, consider a listener task in a server. As the listener accepts
incoming connections, it spawns new tasks that handle those connections. We
might want to have a span representing the listener, and instrument each
spawned handler task with its own span. We would want our instrumentation to
record that the handler tasks were spawned as a result of the listener task.
However, we might not consider the handler tasks to be <em>part</em> of the time
spent in the listener task, so we would not consider those spans children of
the listener span. Instead, we would record that the handler tasks follow
from the listener, recording the causal relationship but treating the spans
as separate durations.</p>
<h3 id="closing-spans"><a class="doc-anchor" href="#closing-spans">§</a>Closing Spans</h3>
<p>Execution may enter and exit a span multiple times before that span is
<em>closed</em>. Consider, for example, a future which has an associated
span and enters that span every time it is polled:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>MyFuture {
<span class="comment">// data
</span>span: tracing::Span,
}
<span class="kw">impl </span>Future <span class="kw">for </span>MyFuture {
<span class="kw">type </span>Output = ();
<span class="kw">fn </span>poll(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, _cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">let </span>_enter = <span class="self">self</span>.span.enter();
<span class="comment">// Do actual future work...
</span>}
}</code></pre></div>
<p>If this future was spawned on an executor, it might yield one or more times
before <code>poll</code> returns <a href="https://doc.rust-lang.org/1.93.1/core/task/poll/enum.Poll.html#variant.Ready" title="variant core::task::poll::Poll::Ready"><code>Poll::Ready</code></a>. If the future were to yield, then
the executor would move on to poll the next future, which may <em>also</em> enter
an associated span or series of spans. Therefore, it is valid for a span to
be entered repeatedly before it completes. Only the time when that span or
one of its children was the current span is considered to be time spent in
that span. A span which is not executing and has not yet been closed is said
to be <em>idle</em>.</p>
<p>Because spans may be entered and exited multiple times before they close,
<a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>s have separate trait methods which are called to notify them
of span exits and when span handles are dropped. When execution exits a
span, <a href="../trait.Subscriber.html#tymethod.exit" title="method tracing::Subscriber::exit"><code>exit</code></a> will always be called with that spans ID to notify the
subscriber that the span has been exited. When span handles are dropped, the
<a href="../trait.Subscriber.html#method.drop_span" title="method tracing::Subscriber::drop_span"><code>drop_span</code></a> method is called with that spans ID. The subscriber may use
this to determine whether or not the span will be entered again.</p>
<p>If there is only a single handle with the capacity to exit a span, dropping
that handle “closes” the span, since the capacity to enter it no longer
exists. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>{
<span class="macro">span!</span>(Level::TRACE, <span class="string">"my_span"</span>).in_scope(|| {
<span class="comment">// perform some work in the context of `my_span`...
</span>}); <span class="comment">// --&gt; Subscriber::exit(my_span)
// The handle to `my_span` only lives inside of this block; when it is
// dropped, the subscriber will be informed via `drop_span`.
</span>} <span class="comment">// --&gt; Subscriber::drop_span(my_span)</span></code></pre></div>
<p>However, if multiple handles exist, the span can still be re-entered even if
one or more is dropped. For determining when <em>all</em> handles to a span have
been dropped, <code>Subscriber</code>s have a <a href="../trait.Subscriber.html#method.clone_span" title="method tracing::Subscriber::clone_span"><code>clone_span</code></a> method, which is called
every time a span handle is cloned. Combined with <code>drop_span</code>, this may be
used to track the number of handles to a given span — if <code>drop_span</code> has
been called one more time than the number of calls to <code>clone_span</code> for a
given ID, then no more handles to the span with that ID exist. The
subscriber may then treat it as closed.</p>
<h2 id="when-to-use-spans"><a class="doc-anchor" href="#when-to-use-spans">§</a>When to use spans</h2>
<p>As a rule of thumb, spans should be used to represent discrete units of work
(e.g., a given requests lifetime in a server) or periods of time spent in a
given context (e.g., time spent interacting with an instance of an external
system, such as a database).</p>
<p>Which scopes in a program correspond to new spans depend somewhat on user
intent. For example, consider the case of a loop in a program. Should we
construct one span and perform the entire loop inside of that span, like:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my_loop"</span>);
<span class="kw">let </span>_enter = span.enter();
<span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..n {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Or, should we create a new span for each iteration of the loop, as in:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">for </span>i <span class="kw">in </span><span class="number">0</span>..n {
<span class="kw">let </span>span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my_loop"</span>, iteration = i);
<span class="kw">let </span>_enter = span.enter();
<span class="comment">// ...
</span>}</code></pre></div>
<p>Depending on the circumstances, we might want to do either, or both. For
example, if we want to know how long was spent in the loop overall, we would
create a single span around the entire loop; whereas if we wanted to know how
much time was spent in each individual iteration, we would enter a new span
on every iteration.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Attributes.html" title="struct tracing::span::Attributes">Attributes</a></dt><dd>Attributes provided to a <code>Subscriber</code> describing a new span when it is
created.</dd><dt><a class="struct" href="struct.Entered.html" title="struct tracing::span::Entered">Entered</a></dt><dd>A guard representing a span which has been entered and is currently
executing.</dd><dt><a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">Entered<wbr>Span</a></dt><dd>An owned version of <a href="struct.Entered.html" title="struct tracing::span::Entered"><code>Entered</code></a>, a guard representing a span which has been
entered and is currently executing.</dd><dt><a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a></dt><dd>Identifies a span within the context of a subscriber.</dd><dt><a class="struct" href="struct.Record.html" title="struct tracing::span::Record">Record</a></dt><dd>A set of fields recorded by a span.</dd><dt><a class="struct" href="struct.Span.html" title="struct tracing::span::Span">Span</a></dt><dd>A handle representing a span, with the capability to enter the span if it
exists.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.AsId.html" title="trait tracing::span::AsId">AsId</a></dt><dd>Trait implemented by types which have a span <code>Id</code>.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Attributes","Entered","EnteredSpan","Id","Record","Span"],"trait":["AsId"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
<!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="Trait implemented by types which have a span `Id`."><title>AsId in tracing::span - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">AsId</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">AsId</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.as_id" title="as_id">as_id</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>span</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">span</a></div><h1>Trait <span class="trait">AsId</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/span.rs.html#336-340">Source</a> </span></div><pre class="rust item-decl"><code>pub trait AsId: Sealed {
// Required method
fn <a href="#tymethod.as_id" class="fn">as_id</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait implemented by types which have a span <code>Id</code>.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.as_id" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#339">Source</a><h4 class="code-header">fn <a href="#tymethod.as_id" class="fn">as_id</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the <code>Id</code> of the span that <code>self</code> corresponds to, or <code>None</code> if
this corresponds to a disabled span.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/tracing/span/trait.AsId.js" async></script></section></div></main></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
<!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="Sets the `Subscriber` as the default for the current thread for the duration of the lifetime of the returned `DefaultGuard`."><title>set_default in tracing::subscriber - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">set_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>subscriber</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">subscriber</a></div><h1>Function <span class="fn">set_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/subscriber.rs.html#57-62">Source</a> </span></div><pre class="rust item-decl"><code>pub fn set_default&lt;S&gt;(subscriber: S) -&gt; <a class="struct" href="../dispatcher/struct.DefaultGuard.html" title="struct tracing::dispatcher::DefaultGuard">DefaultGuard</a><div class="where">where
S: <a class="trait" href="../trait.Subscriber.html" title="trait tracing::Subscriber">Subscriber</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sets the <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> as the default for the current thread for the
duration of the lifetime of the returned <a href="../dispatcher/struct.DefaultGuard.html" title="struct tracing::dispatcher::DefaultGuard"><code>DefaultGuard</code></a>.</p>
<p>The default subscriber is used when creating a new <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a> or <a href="../struct.Event.html" title="struct tracing::Event"><code>Event</code></a>.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,8 @@
<!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="Sets this subscriber as the global default for the duration of the entire program. Will be used as a fallback if no thread-local subscriber has been set in a thread (using `with_default`.)"><title>set_global_default in tracing::subscriber - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">set_global_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>subscriber</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">subscriber</a></div><h1>Function <span class="fn">set_<wbr>global_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/subscriber.rs.html#38-43">Source</a> </span></div><pre class="rust item-decl"><code>pub fn set_global_default&lt;S&gt;(subscriber: S) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="../dispatcher/struct.SetGlobalDefaultError.html" title="struct tracing::dispatcher::SetGlobalDefaultError">SetGlobalDefaultError</a>&gt;<div class="where">where
S: <a class="trait" href="../trait.Subscriber.html" title="trait tracing::Subscriber">Subscriber</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sets this subscriber as the global default for the duration of the entire program.
Will be used as a fallback if no thread-local subscriber has been set in a thread (using <code>with_default</code>.)</p>
<p>Can only be set once; subsequent attempts to set the global default will fail.
Returns whether the initialization was successful.</p>
<p>Note: Libraries should <em>NOT</em> call <code>set_global_default()</code>! That will cause conflicts when
executables try to set them later.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,6 @@
<!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="Sets this `Subscriber` as the default for the current thread for the duration of a closure."><title>with_default in tracing::subscriber - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">with_default</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In tracing::<wbr>subscriber</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a>::<wbr><a href="index.html">subscriber</a></div><h1>Function <span class="fn">with_<wbr>default</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/subscriber.rs.html#20-25">Source</a> </span></div><pre class="rust item-decl"><code>pub fn with_default&lt;T, S&gt;(subscriber: S, f: impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; T) -&gt; T<div class="where">where
S: <a class="trait" href="../trait.Subscriber.html" title="trait tracing::Subscriber">Subscriber</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sets this <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> as the default for the current thread for the
duration of a closure.</p>
<p>The default subscriber is used when creating a new <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a> or
<a href="../struct.Event.html" title="struct tracing::Event"><code>Event</code></a>.</p>
</div></details></section></div></main></body></html>

View File

@@ -0,0 +1,6 @@
<!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="Collects and records trace data."><title>tracing::subscriber - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module subscriber</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module subscriber</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">tracing</a></div><h1>Module <span>subscriber</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/tracing/subscriber.rs.html#1-64">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Collects and records trace data.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.DefaultGuard.html" title="struct tracing::subscriber::DefaultGuard">Default<wbr>Guard</a></dt><dd>A guard that resets the current default dispatcher to the prior
default dispatcher when dropped.</dd><dt><a class="struct" href="struct.Interest.html" title="struct tracing::subscriber::Interest">Interest</a></dt><dd>Indicates a <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>s interest in a particular callsite.</dd><dt><a class="struct" href="struct.NoSubscriber.html" title="struct tracing::subscriber::NoSubscriber">NoSubscriber</a></dt><dd>A no-op <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>.</dd><dt><a class="struct" href="struct.SetGlobalDefaultError.html" title="struct tracing::subscriber::SetGlobalDefaultError">SetGlobal<wbr>Default<wbr>Error</a></dt><dd>Returned if setting the global dispatcher fails.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Subscriber.html" title="trait tracing::subscriber::Subscriber">Subscriber</a></dt><dd>Trait representing the functions required to collect trace data.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.set_default.html" title="fn tracing::subscriber::set_default">set_<wbr>default</a></dt><dd>Sets the <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> as the default for the current thread for the
duration of the lifetime of the returned <a href="../dispatcher/struct.DefaultGuard.html" title="struct tracing::dispatcher::DefaultGuard"><code>DefaultGuard</code></a>.</dd><dt><a class="fn" href="fn.set_global_default.html" title="fn tracing::subscriber::set_global_default">set_<wbr>global_<wbr>default</a></dt><dd>Sets this subscriber as the global default for the duration of the entire program.
Will be used as a fallback if no thread-local subscriber has been set in a thread (using <code>with_default</code>.)</dd><dt><a class="fn" href="fn.with_default.html" title="fn tracing::subscriber::with_default">with_<wbr>default</a></dt><dd>Sets this <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> as the default for the current thread for the
duration of a closure.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["set_default","set_global_default","with_default"],"struct":["DefaultGuard","Interest","NoSubscriber","SetGlobalDefaultError"],"trait":["Subscriber"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,69 @@
<!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="Attaches spans to a `std::future::Future`."><title>Instrument in tracing - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="tracing" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="icon" href="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Instrument</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/main/assets/logo-type.png" alt="logo"></a><h2><a href="../tracing/index.html">tracing</a><span class="version">0.1.44</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Instrument</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.in_current_span" title="in_current_span">in_current_span</a></li><li><a href="#method.instrument" title="instrument">instrument</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate tracing</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">tracing</a></div><h1>Trait <span class="trait">Instrument</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/tracing/instrument.rs.html#20-131">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Instrument: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
// Provided methods
fn <a href="#method.instrument" class="fn">instrument</a>(self, span: <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>) -&gt; <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a> { ... }
<span class="item-spacer"></span> fn <a href="#method.in_current_span" class="fn">in_current_span</a>(self) -&gt; <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Attaches spans to a <a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>std::future::Future</code></a>.</p>
<p>Extension trait allowing futures to be
instrumented with a <code>tracing</code> <a href="struct.Span.html" title="struct tracing::Span">span</a>.</p>
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method"><a class="src rightside" href="../src/tracing/instrument.rs.html#86-91">Source</a><h4 class="code-header">fn <a href="#method.instrument" class="fn">instrument</a>(self, span: <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>) -&gt; <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a></h4></section></summary><div class="docblock"><p>Instruments this type with the provided <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code></a>, returning an
<code>Instrumented</code> wrapper.</p>
<p>The attached <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code></a> will be <a href="struct.Span.html#method.enter" title="method tracing::Span::enter">entered</a> every time the instrumented
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> is polled or <a href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop"><code>Drop</code></a>ped.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<p>Instrumenting a future:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">let </span>my_future = <span class="kw">async </span>{
<span class="comment">// ...
</span>};
my_future
.instrument(<span class="macro">tracing::info_span!</span>(<span class="string">"my_future"</span>))
.<span class="kw">await</span></code></pre></div>
<p>The <a href="struct.Span.html#method.or_current" title="method tracing::Span::or_current"><code>Span::or_current</code></a> combinator can be used in combination with
<code>instrument</code> to ensure that the <a href="struct.Span.html#method.current" title="associated function tracing::Span::current">current span</a> is attached to the
future if the span passed to <code>instrument</code> is <a href="struct.Span.html#method.is_disabled" title="method tracing::Span::is_disabled">disabled</a>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">let </span>my_future = <span class="kw">async </span>{
<span class="comment">// ...
</span>};
<span class="kw">let </span>outer_span = <span class="macro">tracing::info_span!</span>(<span class="string">"outer"</span>).entered();
<span class="comment">// If the "my_future" span is enabled, then the spawned task will
// be within both "my_future" *and* "outer", since "outer" is
// "my_future"'s parent. However, if "my_future" is disabled,
// the spawned task will *not* be in any span.
</span>tokio::spawn(
my_future
.instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">"my_future"</span>))
);
<span class="comment">// Using `Span::or_current` ensures the spawned task is instrumented
// with the current span, if the new span passed to `instrument` is
// not enabled. This means that if the "my_future" span is disabled,
// the spawned task will still be instrumented with the "outer" span:
</span>tokio::spawn(
my_future
.instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">"my_future"</span>).or_current())
);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method"><a class="src rightside" href="../src/tracing/instrument.rs.html#128-130">Source</a><h4 class="code-header">fn <a href="#method.in_current_span" class="fn">in_current_span</a>(self) -&gt; <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt; <a href="#" class="tooltip" data-notable-ty="Instrumented&lt;Self&gt;"></a></h4></section></summary><div class="docblock"><p>Instruments this type with the <a href="struct.Span.html#method.current" title="associated function tracing::Span::current">current</a> <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code></a>, returning an
<code>Instrumented</code> wrapper.</p>
<p>The attached <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code></a> will be <a href="struct.Span.html#method.enter" title="method tracing::Span::enter">entered</a> every time the instrumented
<a href="https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html" title="trait core::future::future::Future"><code>Future</code></a> is polled or <a href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop"><code>Drop</code></a>ped.</p>
<p>This can be used to propagate the current span when spawning a new future.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">let </span>span = <span class="macro">tracing::info_span!</span>(<span class="string">"my_span"</span>);
<span class="kw">let </span>_enter = span.enter();
<span class="comment">// ...
</span><span class="kw">let </span>future = <span class="kw">async </span>{
<span class="macro">tracing::debug!</span>(<span class="string">"this event will occur inside `my_span`"</span>);
<span class="comment">// ...
</span>};
tokio::spawn(future.in_current_span());</code></pre></div></div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Instrument-for-T" class="impl"><a class="src rightside" href="../src/tracing/instrument.rs.html#325">Source</a><a href="#impl-Instrument-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.Instrument.html" title="trait tracing::Instrument">Instrument</a> for T</h3></section></div><script src="../trait.impl/tracing/instrument/trait.Instrument.js" async></script><script type="text/json" id="notable-traits-data">{"Instrumented<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"instrument/struct.Instrumented.html\" title=\"struct tracing::instrument::Instrumented\">Instrumented</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"instrument/struct.Instrumented.html\" title=\"struct tracing::instrument::Instrumented\">Instrumented</a>&lt;T&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.93.1/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>"}</script></section></div></main></body></html>

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More