edlang/tracing/struct.Span.html
2024-04-09 11:05:04 +00:00

521 lines
88 KiB
HTML
Raw 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="A handle representing a span, with the capability to enter the span if it exists."><title>Span in tracing - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-5bc39a1768837dd0.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.77.1 (7cf61ebde 2024-03-27)" data-channel="1.77.1" data-search-js="search-dd67cee4cfa65049.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-4c98445ec4002617.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-48f368f3872407c8.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-04d5337699b92874.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><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="#">Span</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.child_of">child_of</a></li><li><a href="#method.current">current</a></li><li><a href="#method.enter">enter</a></li><li><a href="#method.entered">entered</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">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.new">new</a></li><li><a href="#method.new_disabled">new_disabled</a></li><li><a href="#method.new_root">new_root</a></li><li><a href="#method.none">none</a></li><li><a href="#method.or_current">or_current</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-Clone-for-Span">Clone</a></li><li><a href="#impl-Debug-for-Span">Debug</a></li><li><a href="#impl-Drop-for-Span">Drop</a></li><li><a href="#impl-From%3C%26Span%3E-for-Option%3C%26Id%3E">From&lt;&amp;&#x27;a Span&gt;</a></li><li><a href="#impl-From%3C%26Span%3E-for-Option%3CId%3E">From&lt;&amp;&#x27;a Span&gt;</a></li><li><a href="#impl-From%3CSpan%3E-for-Option%3CId%3E">From&lt;Span&gt;</a></li><li><a href="#impl-Hash-for-Span">Hash</a></li><li><a href="#impl-PartialEq-for-Span">PartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-Span">!RefUnwindSafe</a></li><li><a href="#impl-UnwindSafe-for-Span">!UnwindSafe</a></li><li><a href="#impl-Send-for-Span">Send</a></li><li><a href="#impl-Sync-for-Span">Sync</a></li><li><a href="#impl-Unpin-for-Span">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-ToOwned-for-T">ToOwned</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 crate tracing</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../tracing/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="index.html">tracing</a>::<wbr><a class="struct" href="#">Span</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/tracing/span.rs.html#348-358">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 Span { <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>A handle representing a span, with the capability to enter the span if it
exists.</p>
<p>If the span was rejected by the current <code>Subscriber</code>s filter, entering the
span will silently do nothing. Thus, the handle can be used in the same
manner regardless of whether or not the trace is currently being collected.</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-Span" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#422-1373">source</a><a href="#impl-Span" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#436-438">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(meta: &amp;'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'static&gt;, values: &amp;<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a>&lt;'_&gt;) -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Constructs a new <code>Span</code> with the given <a href="struct.Metadata.html" title="struct tracing::Metadata">metadata</a> and set of
<a href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">field values</a>.</p>
<p>The new span will be constructed by the currently-active <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>,
with the current span as its parent (if one exists).</p>
<p>After the span is constructed, <a href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">field values</a> and/or <a href="struct.Span.html#method.follows_from" title="method tracing::Span::follows_from"><code>follows_from</code></a>
annotations may be added to it.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_root" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#460-462">source</a><h4 class="code-header">pub fn <a href="#method.new_root" class="fn">new_root</a>(meta: &amp;'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'static&gt;, values: &amp;<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a>&lt;'_&gt;) -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Constructs a new <code>Span</code> as the root of its own trace tree, with the
given <a href="struct.Metadata.html" title="struct tracing::Metadata">metadata</a> and set of <a href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">field values</a>.</p>
<p>After the span is constructed, <a href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">field values</a> and/or <a href="struct.Span.html#method.follows_from" title="method tracing::Span::follows_from"><code>follows_from</code></a>
annotations may be added to it.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.child_of" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#484-493">source</a><h4 class="code-header">pub fn <a href="#method.child_of" class="fn">child_of</a>(
parent: impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;&gt;,
meta: &amp;'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'static&gt;,
values: &amp;<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a>&lt;'_&gt;
) -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Constructs a new <code>Span</code> as child of the given parent span, with the
given <a href="struct.Metadata.html" title="struct tracing::Metadata">metadata</a> and set of <a href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">field values</a>.</p>
<p>After the span is constructed, <a href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">field values</a> and/or <a href="struct.Span.html#method.follows_from" title="method tracing::Span::follows_from"><code>follows_from</code></a>
annotations may be added to it.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_disabled" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#519-524">source</a><h4 class="code-header">pub fn <a href="#method.new_disabled" class="fn">new_disabled</a>(meta: &amp;'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'static&gt;) -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Constructs a new disabled span with the given <code>Metadata</code>.</p>
<p>This should be used when a span is constructed from a known callsite,
but the subscriber indicates that it is disabled.</p>
<p>Entering, exiting, and recording values on this span will not notify the
<code>Subscriber</code> but <em>may</em> record log messages if the <code>log</code> feature flag is
enabled.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.none" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#533-538">source</a><h4 class="code-header">pub const fn <a href="#method.none" class="fn">none</a>() -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Constructs a new span that is <em>completely disabled</em>.</p>
<p>This can be used rather than <code>Option&lt;Span&gt;</code> to represent cases where a
span is not present.</p>
<p>Entering, exiting, and recording values on this span will do nothing.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.current" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#549-561">source</a><h4 class="code-header">pub fn <a href="#method.current" class="fn">current</a>() -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class="docblock"><p>Returns a handle to the span <a href="trait.Subscriber.html#method.current_span" title="method tracing::Subscriber::current_span">considered by the <code>Subscriber</code></a> to be the
current span.</p>
<p>If the subscriber indicates that it does not track the current span, or
that the thread from which this function is called is not currently
inside a span, the returned span will be disabled.</p>
</div></details><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="span/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="span/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.entered" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#896-902">source</a><h4 class="code-header">pub fn <a href="#method.entered" class="fn">entered</a>(self) -&gt; <a class="struct" href="span/struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h4></section></summary><div class="docblock"><p>Enters this span, consuming it and returning a <a href="span/struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">guard</a>
that will exit the span when dropped.</p>
<pre class="compile_fail" style="white-space:normal;font:inherit;">
<strong>Warning</strong>: In asynchronous code that uses async/await syntax,
<code>Span::entered</code> may produce incorrect traces if the returned drop
guard is held across an await point. See <a href="#in-asynchronous-code">the
<code>Span::enter</code> documentation</a> for details.
</pre>
<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="span/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>
<p>This is similar to the <a href="struct.Span.html#method.enter" title="method tracing::Span::enter"><code>Span::enter</code></a> method, except that it moves the
span by value into the returned guard, rather than borrowing it.
Therefore, this method can be used to create and enter a span in a
single expression, without requiring a <code>let</code>-binding. For example:</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">"something_interesting"</span>).entered();</code></pre></div>
<p>rather than:</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">"something_interesting"</span>);
<span class="kw">let </span>_e = span.enter();</code></pre></div>
<p>Furthermore, <code>entered</code> may be used when the span must be stored in some
other struct or be passed to a function while remaining entered.</p>
<pre class="ignore" style="white-space:normal;font:inherit;">
<strong>Note</strong>: The returned <a href="../struct.EnteredSpan.html">
<code>EnteredSpan</code></a> guard does not implement <code>Send</code>.
Dropping the guard will exit <em>this</em> span, and if the guard is sent
to another thread and dropped there, that thread may never have entered
this span. Thus, <code>EnteredSpan</code>s should not be sent between threads.
</pre>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<p>The returned guard can be <a href="span/struct.EnteredSpan.html#method.exit" title="method tracing::span::EnteredSpan::exit">explicitly exited</a>,
returning the un-entered 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">"doing_something"</span>).entered();
<span class="comment">// code here is within the span
// explicitly exit the span, returning it
</span><span class="kw">let </span>span = span.exit();
<span class="comment">// code here is no longer within the span
// enter the span again
</span><span class="kw">let </span>span = span.entered();
<span class="comment">// now we are inside the span once again</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>).entered();
<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>Since the <a href="span/struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan"><code>EnteredSpan</code></a> guard can dereference to the <a href="struct.Span.html" title="struct tracing::Span"><code>Span</code></a> itself,
the span may still be accessed while entered. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::field;
<span class="comment">// create the span with an empty field, and enter it.
</span><span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">"my_span"</span>, some_field = field::Empty).entered();
<span class="comment">// we can still record a value for the field while the span is entered.
</span>span.record(<span class="string">"some_field"</span>, <span class="kw-2">&amp;</span><span class="string">"hello world!"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.or_current" class="method"><a class="src rightside" href="../src/tracing/span.rs.html#1027-1032">source</a><h4 class="code-header">pub fn <a href="#method.or_current" class="fn">or_current</a>(self) -&gt; Self</h4></section></summary><div class="docblock"><p>Returns this span, if it was <a href="trait.Subscriber.html#tymethod.enabled" title="method tracing::Subscriber::enabled">enabled</a> by the current <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a>, or
the <a href="struct.Span.html#method.current" title="associated function tracing::Span::current">current span</a> (whose lexical distance may be further than expected),
if this span <a href="struct.Span.html#method.is_disabled" title="method tracing::Span::is_disabled">is disabled</a>.</p>
<p>This method can be useful when propagating spans to spawned threads or
<a href="https://doc.rust-lang.org/1.77.1/std/task/index.html" title="mod std::task">async tasks</a>. Consider the following:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>_parent_span = <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).entered();
<span class="comment">// ...
</span><span class="kw">let </span>child_span = <span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>);
std::thread::spawn(<span class="kw">move </span>|| {
<span class="kw">let </span>_entered = child_span.entered();
<span class="macro">tracing::info!</span>(<span class="string">"spawned a thread!"</span>);
<span class="comment">// ...
</span>});</code></pre></div>
<p>If the current <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> enables the <a href="struct.Level.html#associatedconstant.DEBUG" title="associated constant tracing::Level::DEBUG"><code>DEBUG</code></a> level, then both
the “parent” and “child” spans will be enabled. Thus, when the “spawaned
a thread!” event occurs, it will be inside of the “child” span. Because
“parent” is the parent of “child”, the event will <em>also</em> be inside of
“parent”.</p>
<p>However, if the <a href="trait.Subscriber.html" title="trait tracing::Subscriber"><code>Subscriber</code></a> only enables the <a href="struct.Level.html#associatedconstant.INFO" title="associated constant tracing::Level::INFO"><code>INFO</code></a> level, the “child”
span will be disabled. When the thread is spawned, the
<code>child_span.entered()</code> call will do nothing, since “child” is not
enabled. In this case, the “spawned a thread!” event occurs outside of
<em>any</em> span, since the “child” span was responsible for propagating its
parent to the spawned thread.</p>
<p>If this is not the desired behavior, <code>Span::or_current</code> can be used to
ensure that the “parent” span is propagated in both cases, either as a
parent of “child” <em>or</em> directly. For example:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>_parent_span = <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).entered();
<span class="comment">// ...
// If DEBUG is enabled, then "child" will be enabled, and `or_current`
// returns "child". Otherwise, if DEBUG is not enabled, "child" will be
// disabled, and `or_current` returns "parent".
</span><span class="kw">let </span>child_span = <span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>).or_current();
std::thread::spawn(<span class="kw">move </span>|| {
<span class="kw">let </span>_entered = child_span.entered();
<span class="macro">tracing::info!</span>(<span class="string">"spawned a thread!"</span>);
<span class="comment">// ...
</span>});</code></pre></div>
<p>When spawning <a href="https://doc.rust-lang.org/1.77.1/std/task/index.html" title="mod std::task">asynchronous tasks</a>, <code>Span::or_current</code> can
be used similarly, in combination with <a href="trait.Instrument.html#method.instrument" title="method tracing::Instrument::instrument"><code>instrument</code></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>_parent_span = <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).entered();
<span class="comment">// ...
</span><span class="kw">let </span>child_span = <span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>);
tokio::spawn(
<span class="kw">async </span>{
<span class="macro">tracing::info!</span>(<span class="string">"spawned a task!"</span>);
<span class="comment">// ...
</span>}.instrument(child_span.or_current())
);</code></pre></div>
<p>In general, <code>or_current</code> should be preferred over nesting an
<a href="trait.Instrument.html#method.instrument" title="method tracing::Instrument::instrument"><code>instrument</code></a> call inside of an <a href="trait.Instrument.html#method.in_current_span" title="method tracing::Instrument::in_current_span"><code>in_current_span</code></a> call, as using
<code>or_current</code> will be more efficient.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tracing::Instrument;
<span class="kw">async fn </span>my_async_fn() {
<span class="comment">// ...
</span>}
<span class="kw">let </span>_parent_span = <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).entered();
<span class="comment">// Do this:
</span>tokio::spawn(
my_async_fn().instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>).or_current())
);
<span class="comment">// ...rather than this:
</span>tokio::spawn(
my_async_fn()
.instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>))
.in_current_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.77.1/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-2"><a class="doc-anchor" href="#examples-2">§</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.77.1/std/primitive.reference.html">&amp;Q</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/std/primitive.reference.html">&amp;Q</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/std/primitive.reference.html">&amp;Q</a>, value: V) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>&gt;&gt;) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.1/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-3"><a class="doc-anchor" href="#examples-3">§</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" 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" class="fn">id</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="span/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.77.1/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.77.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>((&amp;<a class="struct" href="span/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.77.1/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></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-Clone-for-Span" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#347">source</a><a href="#impl-Clone-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../src/tracing/span.rs.html#347">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&amp;self) -&gt; <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.77.1/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.77.1/src/core/clone.rs.html#169">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.reference.html">&amp;Self</a>)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.77.1/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Span" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1392-1423">source</a><a href="#impl-Debug-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</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#1393-1422">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/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.77.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-Span" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1455-1476">source</a><a href="#impl-Drop-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</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#1457-1475">source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/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.77.1/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%26Span%3E-for-Option%3C%26Id%3E" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1425-1429">source</a><a href="#impl-From%3C%26Span%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.77.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>&gt; for <a class="enum" href="https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;'a <a class="struct" href="span/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-2" class="method trait-impl"><a class="src rightside" href="../src/tracing/span.rs.html#1426-1428">source</a><a href="#method.from-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(span: &amp;'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</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%26Span%3E-for-Option%3CId%3E" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1431-1435">source</a><a href="#impl-From%3C%26Span%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.77.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;&amp;'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>&gt; for <a class="enum" href="https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="span/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#1432-1434">source</a><a href="#method.from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(span: &amp;'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</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%3CSpan%3E-for-Option%3CId%3E" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1437-1441">source</a><a href="#impl-From%3CSpan%3E-for-Option%3CId%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>&gt; for <a class="enum" href="https://doc.rust-lang.org/1.77.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="span/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#1438-1440">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(span: <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</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-Hash-for-Span" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1386-1390">source</a><a href="#impl-Hash-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl"><a class="src rightside" href="../src/tracing/span.rs.html#1387-1389">source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a>&lt;H: <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>&gt;(&amp;self, hasher: <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.reference.html">&amp;mut H</a>)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="src" href="https://doc.rust-lang.org/1.77.1/src/core/hash/mod.rs.html#238-240">source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a>&lt;H&gt;(data: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.reference.html">&amp;mut H</a>)<div class="where">where
H: <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.77.1/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-Span" class="impl"><a class="src rightside" href="../src/tracing/span.rs.html#1375-1384">source</a><a href="#impl-PartialEq-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../src/tracing/span.rs.html#1376-1383">source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.reference.html">&amp;Self</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.77.1/src/core/cmp.rs.html#242">source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
sufficient, and should not be overridden without very good reason.</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-RefUnwindSafe-for-Span" class="impl"><a href="#impl-RefUnwindSafe-for-Span" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.77.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section><section id="impl-Send-for-Span" class="impl"><a href="#impl-Send-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section><section id="impl-Sync-for-Span" class="impl"><a href="#impl-Sync-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section><section id="impl-Unpin-for-Span" class="impl"><a href="#impl-Unpin-for-Span" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section><section id="impl-UnwindSafe-for-Span" class="impl"><a href="#impl-UnwindSafe-for-Span" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.77.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/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.77.1/src/core/convert/mod.rs.html#764">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.77.1/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-3" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.77.1/src/core/convert/mod.rs.html#767">source</a><a href="#method.from-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/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.77.1/src/core/convert/mod.rs.html#747-749">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.77.1/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.77.1/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.77.1/src/core/convert/mod.rs.html#757">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/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.77.1/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-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.77.1/src/alloc/borrow.rs.html#83-85">source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.77.1/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.77.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.77.1/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.77.1/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&amp;self) -&gt; T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.77.1/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.77.1/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/1.77.1/std/primitive.reference.html">&amp;mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.77.1/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></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.77.1/src/core/convert/mod.rs.html#804-806">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.77.1/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.77.1/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-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.77.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.77.1/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.77.1/src/core/convert/mod.rs.html#811">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/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.77.1/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.77.1/src/core/convert/mod.rs.html#789-791">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.77.1/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.77.1/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" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.77.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/src/core/convert/mod.rs.html#796">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.77.1/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.77.1/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.77.1/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.77.1/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.77.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'>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.77.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.77.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.77.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.77.1/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.77.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.77.1/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.77.1/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = T::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/1.77.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>