edlang/tracing/span/struct.EnteredSpan.html
2024-07-26 09:42:18 +00:00

318 lines
62 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="An owned version of `Entered`, a guard representing a span which has been entered and is currently executing."><title>EnteredSpan in tracing::span - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-dd39b87e5fcfba68.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.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><h2><a href="../../tracing/index.html">tracing</a><span class="version">0.1.40</span></h2></div><h2 class="location"><a href="#">EnteredSpan</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.exit">exit</a></li><li><a href="#method.id">id</a></li></ul><h3><a href="#deref-methods-Span">Methods from Deref&lt;Target=Span&gt;</a></h3><ul class="block deref-methods"><li><a href="#method.enter">enter</a></li><li><a href="#method.field">field</a></li><li><a href="#method.follows_from">follows_from</a></li><li><a href="#method.has_field">has_field</a></li><li><a href="#method.id-1">id</a></li><li><a href="#method.in_scope">in_scope</a></li><li><a href="#method.is_disabled">is_disabled</a></li><li><a href="#method.is_none">is_none</a></li><li><a href="#method.metadata">metadata</a></li><li><a href="#method.record">record</a></li><li><a href="#method.record_all">record_all</a></li><li><a href="#method.with_subscriber">with_subscriber</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-EnteredSpan">Debug</a></li><li><a href="#impl-Deref-for-EnteredSpan">Deref</a></li><li><a href="#impl-Drop-for-EnteredSpan">Drop</a></li><li><a href="#impl-From%3C%26EnteredSpan%3E-for-Option%3C%26Id%3E">From&lt;&amp;&#x27;a EnteredSpan&gt;</a></li><li><a href="#impl-From%3C%26EnteredSpan%3E-for-Option%3CId%3E">From&lt;&amp;&#x27;a EnteredSpan&gt;</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-EnteredSpan">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-EnteredSpan">!Send</a></li><li><a href="#impl-UnwindSafe-for-EnteredSpan">!UnwindSafe</a></li><li><a href="#impl-Freeze-for-EnteredSpan">Freeze</a></li><li><a href="#impl-Sync-for-EnteredSpan">Sync</a></li><li><a href="#impl-Unpin-for-EnteredSpan">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-T">From&lt;T&gt;</a></li><li><a href="#impl-Instrument-for-T">Instrument</a></li><li><a href="#impl-Into%3CU%3E-for-T">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto&lt;U&gt;</a></li><li><a href="#impl-WithSubscriber-for-T">WithSubscriber</a></li></ul></section><h2><a href="index.html">In tracing::span</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="../index.html">tracing</a>::<wbr><a href="index.html">span</a>::<wbr><a class="struct" href="#">EnteredSpan</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../../src/tracing/span.rs.html#401-411">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub struct EnteredSpan { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>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.</p>
<p>When the guard is dropped, the span will be exited.</p>
<p>This is returned by the <a href="../struct.Span.html#method.entered" title="method tracing::Span::entered"><code>Span::entered</code></a> function.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-EnteredSpan" class="impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1540-1554">source</a><a href="#impl-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.id" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1542-1544">source</a><h4 class="code-header">pub fn <a href="#method.id" class="fn">id</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;</h4></section></summary><div class="docblock"><p>Returns this spans <code>Id</code>, if it is enabled.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.exit" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1548-1553">source</a><h4 class="code-header">pub fn <a href="#method.exit" class="fn">exit</a>(self) -&gt; <a class="struct" href="../struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Exits this span, returning the underlying <a href="../struct.Span.html" title="struct tracing::Span"><code>Span</code></a>.</p>
</div></details></div></details></div><h2 id="deref-methods-Span" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&lt;Target = <a class="struct" href="../struct.Span.html" title="struct tracing::Span">Span</a>&gt;</span><a href="#deref-methods-Span" class="anchor">§</a></h2><div id="deref-methods-Span-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.enter" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#785-788">source</a><h4 class="code-header">pub fn <a href="#method.enter" class="fn">enter</a>(&amp;self) -&gt; <a class="struct" href="struct.Entered.html" title="struct tracing::span::Entered">Entered</a>&lt;'_&gt;</h4></section></summary><div class="docblock"><p>Enters this span, returning a guard that will exit the span when dropped.</p>
<p>If this span is enabled by the current subscriber, then this function will
call <a href="../trait.Subscriber.html#tymethod.enter" title="method tracing::Subscriber::enter"><code>Subscriber::enter</code></a> with the spans <a href="struct.Id.html" title="struct tracing::span::Id"><code>Id</code></a>, and dropping the guard
will call <a href="../trait.Subscriber.html#tymethod.exit" title="method tracing::Subscriber::exit"><code>Subscriber::exit</code></a>. If the span is disabled, this does
nothing.</p>
<h5 id="in-asynchronous-code"><a class="doc-anchor" href="#in-asynchronous-code">§</a>In Asynchronous Code</h5>
<p><strong>Warning</strong>: in asynchronous code that uses <a href="https://rust-lang.github.io/async-book/01_getting_started/04_async_await_primer.html">async/await syntax</a>,
<code>Span::enter</code> should be used very carefully or avoided entirely. Holding
the drop guard returned by <code>Span::enter</code> across <code>.await</code> points will
result in incorrect traces. For example,</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">async fn </span>my_async_function() {
<span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"my_async_function"</span>);
<span class="comment">// WARNING: This span will remain entered until this
// guard is dropped...
</span><span class="kw">let </span>_enter = span.enter();
<span class="comment">// ...but the `await` keyword may yield, causing the
// runtime to switch to another task, while remaining in
// this span!
</span>some_other_async_function().<span class="kw">await
</span><span class="comment">// ...
</span>}</code></pre></div>
<p>The drop guard returned by <code>Span::enter</code> exits the span when it is
dropped. When an async function or async block yields at an <code>.await</code>
point, the current scope is <em>exited</em>, but values in that scope are
<strong>not</strong> dropped (because the async block will eventually resume
execution from that await point). This means that <em>another</em> task will
begin executing while <em>remaining</em> in the entered span. This results in
an incorrect trace.</p>
<p>Instead of using <code>Span::enter</code> in asynchronous code, prefer the
following:</p>
<ul>
<li>
<p>To enter a span for a synchronous section of code within an async
block or function, prefer <a href="../struct.Span.html#method.in_scope" title="method tracing::Span::in_scope"><code>Span::in_scope</code></a>. Since <code>in_scope</code> takes a
synchronous closure and exits the span when the closure returns, the
span will always be exited before the next await point. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">async fn </span>my_async_function() {
<span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"my_async_function"</span>);
<span class="kw">let </span>some_value = span.in_scope(|| {
<span class="comment">// run some synchronous code inside the span...
</span>});
<span class="comment">// This is okay! The span has already been exited before we reach
// the await point.
</span>some_other_async_function(some_value).<span class="kw">await</span>;
<span class="comment">// ...
</span>}</code></pre></div>
</li>
<li>
<p>For instrumenting asynchronous code, <code>tracing</code> provides the
<a href="../trait.Instrument.html" title="trait tracing::Instrument"><code>Future::instrument</code> combinator</a> for
attaching a span to a future (async function or block). This will
enter the span <em>every</em> time the future is polled, and exit it whenever
the future yields.</p>
<p><code>Instrument</code> can be used with an async block inside an async function:</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::Instrument;
<span class="kw">async fn </span>my_async_function() {
<span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"my_async_function"</span>);
<span class="kw">async move </span>{
<span class="comment">// This is correct! If we yield here, the span will be exited,
// and re-entered when we resume.
</span>some_other_async_function().<span class="kw">await</span>;
<span class="comment">//more asynchronous code inside the span...
</span>}
<span class="comment">// instrument the async block with the span...
</span>.instrument(span)
<span class="comment">// ...and await it.
</span>.<span class="kw">await
</span>}</code></pre></div>
<p>It can also be used to instrument calls to async functions at the
callsite:</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::Instrument;
<span class="kw">async fn </span>my_async_function() {
<span class="kw">let </span>some_value = some_other_async_function()
.instrument(<span class="macro">debug_span!</span>(<span class="string">"some_other_async_function"</span>))
.<span class="kw">await</span>;
<span class="comment">// ...
</span>}</code></pre></div>
</li>
<li>
<p>The <a href="../attr.instrument.html" title="attr tracing::instrument"><code>#[instrument]</code> attribute macro</a> can automatically generate
correct code when used on an async function:</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="attr">#[tracing::instrument(level = <span class="string">"info"</span>)]
</span><span class="kw">async fn </span>my_async_function() {
<span class="comment">// This is correct! If we yield here, the span will be exited,
// and re-entered when we resume.
</span>some_other_async_function().<span class="kw">await</span>;
<span class="comment">// ...
</span>}</code></pre></div>
</li>
</ul>
<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">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">// code here is within the span
</span>drop(guard);
<span class="comment">// code here is no longer within the span
</span></code></pre></div>
<p>Guards need not be explicitly dropped:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>my_function() -&gt; String {
<span class="comment">// enter a span for the duration of this function.
</span><span class="kw">let </span>span = <span class="macro">trace_span!</span>(<span class="string">"my_function"</span>);
<span class="kw">let </span>_enter = span.enter();
<span class="comment">// anything happening in functions we call is still inside the span...
</span>my_other_function();
<span class="comment">// returning from the function drops the guard, exiting the span.
</span><span class="kw">return </span><span class="string">"Hello world"</span>.to_owned();
}
<span class="kw">fn </span>my_other_function() {
<span class="comment">// ...
</span>}</code></pre></div>
<p>Sub-scopes may be created to limit the duration for which the span is
entered:</p>
<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_great_span"</span>);
{
<span class="kw">let </span>_enter = span.enter();
<span class="comment">// this event occurs inside the span.
</span><span class="macro">info!</span>(<span class="string">"i'm in the span!"</span>);
<span class="comment">// exiting the scope drops the guard, exiting the span.
</span>}
<span class="comment">// this event is not inside the span.
</span><span class="macro">info!</span>(<span class="string">"i'm outside the span!"</span>)</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.in_scope" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1100-1103">source</a><h4 class="code-header">pub fn <a href="#method.in_scope" class="fn">in_scope</a>&lt;F: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -&gt; T, T&gt;(&amp;self, f: F) -&gt; T</h4></section></summary><div class="docblock"><p>Executes the given function in the context of this span.</p>
<p>If this span is enabled, then this function enters the span, invokes <code>f</code>
and then exits the span. If the span is disabled, <code>f</code> will still be
invoked, but in the context of the currently-executing span (if there is
one).</p>
<p>Returns the result of evaluating <code>f</code>.</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">let </span>my_span = <span class="macro">span!</span>(Level::TRACE, <span class="string">"my_span"</span>);
my_span.in_scope(|| {
<span class="comment">// this event occurs within the span.
</span><span class="macro">trace!</span>(<span class="string">"i'm in the span!"</span>);
});
<span class="comment">// this event occurs outside the span.
</span><span class="macro">trace!</span>(<span class="string">"i'm not in the span!"</span>);</code></pre></div>
<p>Calling a function and returning the result:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>hello_world() -&gt; String {
<span class="string">"Hello world!"</span>.to_owned()
}
<span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"hello_world"</span>);
<span class="comment">// the span will be entered for the duration of the call to
// `hello_world`.
</span><span class="kw">let </span>a_string = span.in_scope(hello_world);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.field" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1107-1112">source</a><h4 class="code-header">pub fn <a href="#method.field" class="fn">field</a>&lt;Q&gt;(&amp;self, field: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Q</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../field/struct.Field.html" title="struct tracing::field::Field">Field</a>&gt;<div class="where">where
Q: <a class="trait" href="../field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Returns a <a href="../field/struct.Field.html" title="struct tracing::field::Field"><code>Field</code></a> for the field with the
given <code>name</code>, if one exists,</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.has_field" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1117-1122">source</a><h4 class="code-header">pub fn <a href="#method.has_field" class="fn">has_field</a>&lt;Q&gt;(&amp;self, field: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Q</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a><div class="where">where
Q: <a class="trait" href="../field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Returns true if this <code>Span</code> has a field for the given
<a href="../field/struct.Field.html" title="struct tracing::field::Field"><code>Field</code></a> or field name.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1194-1210">source</a><h4 class="code-header">pub fn <a href="#method.record" class="fn">record</a>&lt;Q, V&gt;(&amp;self, field: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Q</a>, value: V) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a><div class="where">where
Q: <a class="trait" href="../field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
V: <a class="trait" href="../trait.Value.html" title="trait tracing::Value">Value</a>,</div></h4></section></summary><div class="docblock"><p>Records that the field described by <code>field</code> has the value <code>value</code>.</p>
<p>This may be used with <a href="../field/struct.Empty.html" title="struct tracing::field::Empty"><code>field::Empty</code></a> to declare fields whose values
are not known when the span is created, and record them later:</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.
// (note that the field name is passed as a string slice)
</span>span.record(<span class="string">"parting"</span>, <span class="string">"goodbye world!"</span>);</code></pre></div>
<p>However, it may also be used to record a <em>new</em> value for a field whose
value was already recorded:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::info_span;
<span class="comment">// Initially, let's assume that our attempt to do something is going okay...
</span><span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"doing_something"</span>, is_okay = <span class="bool-val">true</span>);
<span class="kw">let </span>_e = span.enter();
<span class="kw">match </span>do_something() {
<span class="prelude-val">Ok</span>(something) =&gt; {
<span class="comment">// ...
</span>}
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; {
<span class="comment">// Things are no longer okay!
</span>span.record(<span class="string">"is_okay"</span>, <span class="bool-val">false</span>);
}
}</code></pre></div>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: The fields associated with a span are part
of its <a href="../struct.Metadata.html"><code>Metadata</code></a>.
The <a href="../struct.Metadata.html"><code>Metadata</code></a>
describing a particular span is constructed statically when the span
is created and cannot be extended later to add new fields. Therefore,
you cannot record a value for a field that was not specified when the
span was created:
</pre>
<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, you try to record a value for a new field, `new_field`, which was not
// declared as `Empty` or populated when you created `span`.
// You won't get any error, but the assignment will have no effect!
</span>span.record(<span class="string">"new_field"</span>, <span class="string">"interesting_value_you_really_need"</span>);
<span class="comment">// Instead, all fields that may be recorded after span creation should be declared up front,
// using field::Empty when a value is not known, as we did for `parting`.
// This `record` call will indeed replace field::Empty with "you will be remembered".
</span>span.record(<span class="string">"parting"</span>, <span class="string">"you will be remembered"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.record_all" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1213-1235">source</a><h4 class="code-header">pub fn <a href="#method.record_all" class="fn">record_all</a>(&amp;self, values: &amp;<a class="struct" href="../field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a>&lt;'_&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a></h4></section></summary><div class="docblock"><p>Records all the fields in the provided <code>ValueSet</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_disabled" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1244-1246">source</a><h4 class="code-header">pub fn <a href="#method.is_disabled" class="fn">is_disabled</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if this span was disabled by the subscriber and does not
exist.</p>
<p>See also <a href="../struct.Span.html#method.is_none" title="method tracing::Span::is_none"><code>is_none</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_none" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1259-1261">source</a><h4 class="code-header">pub fn <a href="#method.is_none" class="fn">is_none</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if this span was constructed by <a href="../struct.Span.html#method.none" title="associated function tracing::Span::none"><code>Span::none</code></a> and is
empty.</p>
<p>If <code>is_none</code> returns <code>true</code> for a given span, then <a href="../struct.Span.html#method.is_disabled" title="method tracing::Span::is_disabled"><code>is_disabled</code></a> will
also return <code>true</code>. However, when a span is disabled by the subscriber
rather than constructed by <code>Span::none</code>, this method will return
<code>false</code>, while <code>is_disabled</code> will return <code>true</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.follows_from" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1310-1317">source</a><h4 class="code-header">pub fn <a href="#method.follows_from" class="fn">follows_from</a>(&amp;self, from: impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a></h4></section></summary><div class="docblock"><p>Indicates that the span with the given ID has an indirect causal
relationship with this span.</p>
<p>This relationship differs somewhat from the parent-child relationship: a
span may have any number of prior spans, rather than a single one; and
spans are not considered to be executing <em>inside</em> of the spans they
follow from. This means that a span may close even if subsequent spans
that follow from it are still open, and time spent inside of a
subsequent span should not be included in the time its precedents were
executing. This is used to model causal relationships such as when a
single future spawns several related background tasks, et cetera.</p>
<p>If this span is disabled, or the resulting follows-from relationship
would be invalid, this function will do nothing.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<p>Setting a <code>follows_from</code> relationship with a <code>Span</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span1 = <span class="macro">span!</span>(Level::INFO, <span class="string">"span_1"</span>);
<span class="kw">let </span>span2 = <span class="macro">span!</span>(Level::DEBUG, <span class="string">"span_2"</span>);
span2.follows_from(span1);</code></pre></div>
<p>Setting a <code>follows_from</code> relationship with the current 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::INFO, <span class="string">"hello!"</span>);
span.follows_from(Span::current());</code></pre></div>
<p>Setting a <code>follows_from</code> relationship with a <code>Span</code> reference:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">span!</span>(Level::INFO, <span class="string">"hello!"</span>);
<span class="kw">let </span>curr = Span::current();
span.follows_from(<span class="kw-2">&amp;</span>curr);</code></pre></div>
<p>Setting a <code>follows_from</code> relationship with an <code>Id</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>span = <span class="macro">span!</span>(Level::INFO, <span class="string">"hello!"</span>);
<span class="kw">let </span>id = span.id();
span.follows_from(id);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.id-1" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1320-1322">source</a><h4 class="code-header">pub fn <a href="#method.id-1" class="fn">id</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;</h4></section></summary><div class="docblock"><p>Returns this spans <code>Id</code>, if it is enabled.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.metadata" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1325-1327">source</a><h4 class="code-header">pub fn <a href="#method.metadata" class="fn">metadata</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'static <a class="struct" href="../struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'static&gt;&gt;</h4></section></summary><div class="docblock"><p>Returns this spans <code>Metadata</code>, if it is enabled.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_subscriber" class="method"><a class="src rightside" href="../../src/tracing/span.rs.html#1368-1372">source</a><h4 class="code-header">pub fn <a href="#method.with_subscriber" class="fn">with_subscriber</a>&lt;T&gt;(
&amp;self,
f: impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>((&amp;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>, &amp;<a class="struct" href="../struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>)) -&gt; T,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;</h4></section></summary><div class="docblock"><p>Invokes a function with a reference to this spans ID and subscriber.</p>
<p>if this span is enabled, the provided function is called, and the result is returned.
If the span is disabled, the function is not called, and this method returns <code>None</code>
instead.</p>
</div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-EnteredSpan" class="impl"><a class="src rightside" href="../../src/tracing/span.rs.html#399">source</a><a href="#impl-Debug-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/tracing/span.rs.html#399">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.80.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deref-for-EnteredSpan" class="impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1556-1563">source</a><a href="#impl-Deref-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Target" class="associatedtype trait-impl"><a href="#associatedtype.Target" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/ops/deref/trait.Deref.html#associatedtype.Target" class="associatedtype">Target</a> = <a class="struct" href="../struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class='docblock'>The resulting type after dereferencing.</div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1560-1562">source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/deref/trait.Deref.html#tymethod.deref" class="fn">deref</a>(&amp;self) -&gt; &amp;<a class="struct" href="../struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class='docblock'>Dereferences the value.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-EnteredSpan" class="impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1572-1577">source</a><a href="#impl-Drop-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1574-1576">source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/drop/trait.Drop.html#tymethod.drop" class="fn">drop</a>(&amp;mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.80.0/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C%26EnteredSpan%3E-for-Option%3C%26Id%3E" class="impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1443-1447">source</a><a href="#impl-From%3C%26EnteredSpan%3E-for-Option%3C%26Id%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a>&gt; for <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'a <a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1444-1446">source</a><a href="#method.from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(span: &amp;'a <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a>) -&gt; Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3C%26EnteredSpan%3E-for-Option%3CId%3E" class="impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1449-1453">source</a><a href="#impl-From%3C%26EnteredSpan%3E-for-Option%3CId%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a>&gt; for <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="../../src/tracing/span.rs.html#1450-1452">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(span: &amp;'a <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a>) -&gt; Self</h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-EnteredSpan" class="impl"><a href="#impl-Freeze-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section><section id="impl-RefUnwindSafe-for-EnteredSpan" class="impl"><a href="#impl-RefUnwindSafe-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section><section id="impl-Send-for-EnteredSpan" class="impl"><a href="#impl-Send-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section><section id="impl-Sync-for-EnteredSpan" class="impl"><a href="#impl-Sync-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section><section id="impl-Unpin-for-EnteredSpan" class="impl"><a href="#impl-Unpin-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section><section id="impl-UnwindSafe-for-EnteredSpan" class="impl"><a href="#impl-UnwindSafe-for-EnteredSpan" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#768">source</a><a href="#method.from-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><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&gt; <a class="trait" href="../trait.Instrument.html" title="trait tracing::Instrument">Instrument</a> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl"><a class="src rightside" href="../../src/tracing/instrument.rs.html#86-91">source</a><a href="#method.instrument" class="anchor">§</a><h4 class="code-header">fn <a href="../trait.Instrument.html#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'>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. <a href="../trait.Instrument.html#method.instrument">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl"><a class="src rightside" href="../../src/tracing/instrument.rs.html#128-130">source</a><a href="#method.in_current_span" class="anchor">§</a><h4 class="code-header">fn <a href="../trait.Instrument.html#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'>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. <a href="../trait.Instrument.html#method.in_current_span">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><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&gt; <a class="trait" href="../instrument/trait.WithSubscriber.html" title="trait tracing::instrument::WithSubscriber">WithSubscriber</a> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.with_subscriber-1" class="method trait-impl"><a class="src rightside" href="../../src/tracing/instrument.rs.html#176-184">source</a><a href="#method.with_subscriber-1" class="anchor">§</a><h4 class="code-header">fn <a href="../instrument/trait.WithSubscriber.html#method.with_subscriber" class="fn">with_subscriber</a>&lt;S&gt;(self, subscriber: S) -&gt; <a class="struct" href="../instrument/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.80.0/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'>Attaches the provided <a href="../trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> to this type, returning a
<a href="../instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch"><code>WithDispatch</code></a> wrapper. <a href="../instrument/trait.WithSubscriber.html#method.with_subscriber">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl"><a class="src rightside" href="../../src/tracing/instrument.rs.html#228-233">source</a><a href="#method.with_current_subscriber" class="anchor">§</a><h4 class="code-header">fn <a href="../instrument/trait.WithSubscriber.html#method.with_current_subscriber" class="fn">with_current_subscriber</a>(self) -&gt; <a class="struct" href="../instrument/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'>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="../instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch"><code>WithDispatch</code></a> wrapper. <a href="../instrument/trait.WithSubscriber.html#method.with_current_subscriber">Read more</a></div></details></div></details></div><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.80.0/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.80.0/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.80.0/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>","WithDispatch<Self>":"<h3>Notable traits for <code><a class=\"struct\" href=\"../instrument/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.80.0/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.80.0/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"../instrument/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.80.0/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>;</div>"}</script></section></div></main></body></html>