blob: d194592957717a62fba1958f2966ee346d85437b [file] [log] [blame]
<!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."><meta name="keywords" content="rust, rustlang, rust-lang, Span"><title>Span in tracing - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc 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">&#9776;</button><a class="sidebar-logo" href="../tracing/index.html"><div class="logo-container"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../tracing/index.html"><div class="logo-container">
<img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></div></a><h2 class="location"><a href="#">Span</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><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"><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%26%27a%20Span%3E-for-Option%3C%26%27a%20Id%3E">From&lt;&amp;&#39;a Span&gt;</a></li><li><a href="#impl-From%3C%26%27a%20Span%3E-for-Option%3CId%3E">From&lt;&amp;&#39;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%3CSpan%3E-for-Span">PartialEq&lt;Span&gt;</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-Span">!RefUnwindSafe</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><li><a href="#impl-UnwindSafe-for-Span">!UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-Span">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Span">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Span">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-Span">From&lt;T&gt;</a></li><li><a href="#impl-Instrument-for-Span">Instrument</a></li><li><a href="#impl-Into%3CU%3E-for-Span">Into&lt;U&gt;</a></li><li><a href="#impl-ToOwned-for-Span">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Span">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-Span">TryInto&lt;U&gt;</a></li><li><a href="#impl-WithSubscriber-for-Span">WithSubscriber</a></li></ul></section><h2><a href="index.html">In tracing</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">tracing</a>::<wbr><a class="struct" href="#">Span</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/tracing/span.rs.html#348-358">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Span { /* private fields */ }</code></pre></div><details class="rustdoc-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="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Span" class="impl has-srclink"><a class="srclink 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="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#436-438">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">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">metadata</a> and set of
<a href="field/struct.ValueSet.html">field values</a>.</p>
<p>The new span will be constructed by the currently-active <a href="trait.Subscriber.html"><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">field values</a> and/or <a href="struct.Span.html#method.follows_from"><code>follows_from</code></a>
annotations may be added to it.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_root" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#460-462">source</a><h4 class="code-header">pub fn <a href="#method.new_root" class="fnname">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">metadata</a> and set of <a href="field/struct.ValueSet.html">field values</a>.</p>
<p>After the span is constructed, <a href="field/struct.ValueSet.html">field values</a> and/or <a href="struct.Span.html#method.follows_from"><code>follows_from</code></a>
annotations may be added to it.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.child_of" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#484-493">source</a><h4 class="code-header">pub fn <a href="#method.child_of" class="fnname">child_of</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;parent: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/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;,<br>&nbsp;&nbsp;&nbsp;&nbsp;meta: &amp;'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a>&lt;'static&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;values: &amp;<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a>&lt;'_&gt;<br>) -&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">metadata</a> and set of <a href="field/struct.ValueSet.html">field values</a>.</p>
<p>After the span is constructed, <a href="field/struct.ValueSet.html">field values</a> and/or <a href="struct.Span.html#method.follows_from"><code>follows_from</code></a>
annotations may be added to it.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_disabled" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#519-524">source</a><h4 class="code-header">pub fn <a href="#method.new_disabled" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.none" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#533-538">source</a><h4 class="code-header">pub const fn <a href="#method.none" class="fnname">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="rustdoc-toggle method-toggle" open><summary><section id="method.current" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#549-561">source</a><h4 class="code-header">pub fn <a href="#method.current" class="fnname">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">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="rustdoc-toggle method-toggle" open><summary><section id="method.enter" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#785-788">source</a><h4 class="code-header">pub fn <a href="#method.enter" class="fnname">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"><code>Subscriber::enter</code></a> with the span’s <a href="span/struct.Id.html"><code>Id</code></a>, and dropping the guard
will call <a href="trait.Subscriber.html#tymethod.exit"><code>Subscriber::exit</code></a>. If the span is disabled, this does
nothing.</p>
<h5 id="in-asynchronous-code"><a href="#in-asynchronous-code">In Asynchronous Code</a></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">&quot;my_async_function&quot;</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"><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">&quot;my_async_function&quot;</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"><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"><div class='tooltip'></div><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">&quot;my_async_function&quot;</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"><div class='tooltip'></div><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">&quot;some_other_async_function&quot;</span>))
.<span class="kw">await</span>;
<span class="comment">// ...
</span>}</code></pre></div>
</li>
<li>
<p>The <a href="attr.instrument.html"><code>#[instrument]</code> attribute macro</a> can automatically generate
correct code when used on an async function:</p>
<div class="example-wrap ignore"><div class='tooltip'></div><pre class="rust rust-example-rendered"><code><span class="attribute">#[tracing::instrument(level = <span class="string">&quot;info&quot;</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 href="#examples">Examples</a></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">&quot;my_span&quot;</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">&quot;my_function&quot;</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">&quot;Hello world&quot;</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">&quot;my_great_span&quot;</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">&quot;i&#39;m in the span!&quot;</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">&quot;i&#39;m outside the span!&quot;</span>)</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.entered" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#896-902">source</a><h4 class="code-header">pub fn <a href="#method.entered" class="fnname">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="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"><code>Subscriber::enter</code></a> with the span’s <a href="span/struct.Id.html"><code>Id</code></a>, and dropping the guard
will call <a href="trait.Subscriber.html#tymethod.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="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">&quot;something_interesting&quot;</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">&quot;something_interesting&quot;</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</a></code> 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 href="#examples-1">Examples</a></h5>
<p>The returned guard can be <a href="span/struct.EnteredSpan.html#method.exit" title="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">&quot;doing_something&quot;</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">&quot;my_function&quot;</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">&quot;Hello world&quot;</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="EnteredSpan"><code>EnteredSpan</code></a> guard can dereference to the <a href="struct.Span.html" title="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">&quot;my_span&quot;</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">&quot;some_field&quot;</span>, <span class="kw-2">&amp;</span><span class="string">&quot;hello world!&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.or_current" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1027-1032">source</a><h4 class="code-header">pub fn <a href="#method.or_current" class="fnname">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">enabled</a> by the current <a href="trait.Subscriber.html"><code>Subscriber</code></a>, or
the <a href="struct.Span.html#method.current">current span</a> (whose lexical distance may be further than expected),
if this span <a href="struct.Span.html#method.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/nightly/std/task/index.html">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">&quot;parent&quot;</span>).entered();
<span class="comment">// ...
</span><span class="kw">let </span>child_span = <span class="macro">tracing::debug_span!</span>(<span class="string">&quot;child&quot;</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">&quot;spawned a thread!&quot;</span>);
<span class="comment">// ...
</span>});</code></pre></div>
<p>If the current <a href="trait.Subscriber.html"><code>Subscriber</code></a> enables the <a href="struct.Level.html#associatedconstant.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"><code>Subscriber</code></a> only enables the <a href="struct.Level.html#associatedconstant.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">&quot;parent&quot;</span>).entered();
<span class="comment">// ...
// If DEBUG is enabled, then &quot;child&quot; will be enabled, and `or_current`
// returns &quot;child&quot;. Otherwise, if DEBUG is not enabled, &quot;child&quot; will be
// disabled, and `or_current` returns &quot;parent&quot;.
</span><span class="kw">let </span>child_span = <span class="macro">tracing::debug_span!</span>(<span class="string">&quot;child&quot;</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">&quot;spawned a thread!&quot;</span>);
<span class="comment">// ...
</span>});</code></pre></div>
<p>When spawning <a href="https://doc.rust-lang.org/nightly/std/task/index.html">asynchronous tasks</a>, <code>Span::or_current</code> can
be used similarly, in combination with <a href="trait.Instrument.html#method.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">&quot;parent&quot;</span>).entered();
<span class="comment">// ...
</span><span class="kw">let </span>child_span = <span class="macro">tracing::debug_span!</span>(<span class="string">&quot;child&quot;</span>);
tokio::spawn(
<span class="kw">async </span>{
<span class="macro">tracing::info!</span>(<span class="string">&quot;spawned a task!&quot;</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"><code>instrument</code></a> call inside of an <a href="trait.Instrument.html#method.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">&quot;parent&quot;</span>).entered();
<span class="comment">// Do this:
</span>tokio::spawn(
my_async_fn().instrument(<span class="macro">tracing::debug_span!</span>(<span class="string">&quot;child&quot;</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">&quot;child&quot;</span>))
.in_current_span()
);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.in_scope" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1100-1103">source</a><h4 class="code-header">pub fn <a href="#method.in_scope" class="fnname">in_scope</a>&lt;F:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/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 href="#examples-2">Examples</a></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">&quot;my_span&quot;</span>);
my_span.in_scope(|| {
<span class="comment">// this event occurs within the span.
</span><span class="macro">trace!</span>(<span class="string">&quot;i&#39;m in the span!&quot;</span>);
});
<span class="comment">// this event occurs outside the span.
</span><span class="macro">trace!</span>(<span class="string">&quot;i&#39;m not in the span!&quot;</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">&quot;Hello world!&quot;</span>.to_owned()
}
<span class="kw">let </span>span = <span class="macro">info_span!</span>(<span class="string">&quot;hello_world&quot;</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="rustdoc-toggle method-toggle" open><summary><section id="method.field" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1107-1112">source</a><h4 class="code-header">pub fn <a href="#method.field" class="fnname">field</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;self, field: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Q) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a>,</span></h4></section></summary><div class="docblock"><p>Returns a <a href="field/struct.Field.html" title="super::field::Field"><code>Field</code></a> for the field with the
given <code>name</code>, if one exists,</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.has_field" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1117-1122">source</a><h4 class="code-header">pub fn <a href="#method.has_field" class="fnname">has_field</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;self, field: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Q) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a><span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a>,</span></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="super::field::Field"><code>Field</code></a> or field name.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.record" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1194-1210">source</a><h4 class="code-header">pub fn <a href="#method.record" class="fnname">record</a>&lt;Q:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V&gt;(&amp;self, field: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Q, value: V) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Q: <a class="trait" href="field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="trait.Value.html" title="trait tracing::Value">Value</a>,</span></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"><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 &quot;hello world&quot;, and
// `parting`, without a value.
</span><span class="kw">let </span>span = <span class="macro">trace_span!</span>(<span class="string">&quot;my_span&quot;</span>, greeting = <span class="string">&quot;hello world&quot;</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">&quot;parting&quot;</span>, <span class="string">&quot;goodbye world!&quot;</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&#39;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">&quot;doing_something&quot;</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">&quot;is_okay&quot;</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 &quot;hello world&quot;, and
// `parting`, without a value.
</span><span class="kw">let </span>span = <span class="macro">trace_span!</span>(<span class="string">&quot;my_span&quot;</span>, greeting = <span class="string">&quot;hello world&quot;</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&#39;t get any error, but the assignment will have no effect!
</span>span.record(<span class="string">&quot;new_field&quot;</span>, <span class="string">&quot;interesting_value_you_really_need&quot;</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 &quot;you will be remembered&quot;.
</span>span.record(<span class="string">&quot;parting&quot;</span>, <span class="string">&quot;you will be remembered&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.record_all" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1213-1235">source</a><h4 class="code-header">pub fn <a href="#method.record_all" class="fnname">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/nightly/std/primitive.reference.html">&amp;</a>Self</h4></section></summary><div class="docblock"><p>Records all the fields in the provided <code>ValueSet</code>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_disabled" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1244-1246">source</a><h4 class="code-header">pub fn <a href="#method.is_disabled" class="fnname">is_disabled</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>is_none</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_none" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1259-1261">source</a><h4 class="code-header">pub fn <a href="#method.is_none" class="fnname">is_none</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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"><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="rustdoc-toggle method-toggle" open><summary><section id="method.follows_from" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1310-1317">source</a><h4 class="code-header">pub fn <a href="#method.follows_from" class="fnname">follows_from</a>(&amp;self, from: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.reference.html">&amp;</a>Self</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 href="#examples-3">Examples</a></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">&quot;span_1&quot;</span>);
<span class="kw">let </span>span2 = <span class="macro">span!</span>(Level::DEBUG, <span class="string">&quot;span_2&quot;</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">&quot;hello!&quot;</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">&quot;hello!&quot;</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">&quot;hello!&quot;</span>);
<span class="kw">let </span>id = span.id();
span.follows_from(id);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.id" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1320-1322">source</a><h4 class="code-header">pub fn <a href="#method.id" class="fnname">id</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 span’s <code>Id</code>, if it is enabled.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.metadata" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1325-1327">source</a><h4 class="code-header">pub fn <a href="#method.metadata" class="fnname">metadata</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 span’s <code>Metadata</code>, if it is enabled.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_subscriber" class="method has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1368-1372">source</a><h4 class="code-header">pub fn <a href="#method.with_subscriber" class="fnname">with_subscriber</a>&lt;T&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;f: impl <a class="trait" href="https://doc.rust-lang.org/nightly/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<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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 span’s 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="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone-for-Span" class="impl has-srclink"><a class="srclink 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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><a class="srclink 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/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">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/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#132-134">source</a></span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">const fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Span" class="impl has-srclink"><a class="srclink 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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink 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/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Drop-for-Span" class="impl has-srclink"><a class="srclink 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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl has-srclink"><a class="srclink 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/nightly/core/ops/drop/trait.Drop.html#tymethod.drop" class="fnname">drop</a>(&amp;mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/nightly/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3C%26%27a%20Span%3E-for-Option%3C%26%27a%20Id%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1425-1429">source</a><a href="#impl-From%3C%26%27a%20Span%3E-for-Option%3C%26%27a%20Id%3E" class="anchor"></a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1426-1428">source</a><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3C%26%27a%20Span%3E-for-Option%3CId%3E" class="impl has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1431-1435">source</a><a href="#impl-From%3C%26%27a%20Span%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/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl has-srclink"><a class="srclink 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/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSpan%3E-for-Option%3CId%3E" class="impl has-srclink"><a class="srclink 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/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1438-1440">source</a><a href="#method.from-2" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash-for-Span" class="impl has-srclink"><a class="srclink 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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><a class="srclink 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/nightly/core/hash/trait.Hash.html#tymethod.hash" class="fnname">hash</a>&lt;H:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.reference.html">&amp;mut </a>H)</h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#237-239">source</a></span><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a>&lt;H&gt;(data: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>H)<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,</span></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CSpan%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="../src/tracing/span.rs.html#1375-1384">source</a><a href="#impl-PartialEq%3CSpan%3E-for-Span" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>&gt; for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><a class="srclink 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/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#227">source</a></span><a href="#method.ne" class="anchor"></a><h4 class="code-header">const fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="small-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 has-srclink"><a href="#impl-RefUnwindSafe-for-Span" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Send-for-Span" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Sync-for-Span" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Unpin-for-Span" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-UnwindSafe-for-Span" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/nightly/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="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from-3" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Instrument-for-Span" class="impl has-srclink"><a class="srclink rightside" href="../src/tracing/instrument.rs.html#276">source</a><a href="#impl-Instrument-for-Span" 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="rustdoc-toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tracing/instrument.rs.html#82-84">source</a><a href="#method.instrument" class="anchor"></a><h4 class="code-header">fn <a href="trait.Instrument.html#method.instrument" class="fnname">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;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Instruments this type with the provided <a href="struct.Span.html" title="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="rustdoc-toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tracing/instrument.rs.html#121-123">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="fnname">in_current_span</a>(self) -&gt; <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;Self&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a>&lt;T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Instruments this type with the <a href="struct.Span.html#method.current">current</a> <a href="struct.Span.html"><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="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">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/nightly/core/convert/trait.From.html" title="From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#83">source</a><a href="#impl-ToOwned-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/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/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">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/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/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/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#775">source</a><a href="#impl-TryFrom%3CU%3E-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#781">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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/nightly/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/nightly/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="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Span" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#760">source</a><a href="#impl-TryInto%3CU%3E-for-Span" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#766">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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/nightly/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/nightly/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="rustdoc-toggle implementors-toggle"><summary><section id="impl-WithSubscriber-for-Span" class="impl has-srclink"><a class="srclink rightside" href="../src/tracing/instrument.rs.html#334">source</a><a href="#impl-WithSubscriber-for-Span" 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="rustdoc-toggle method-toggle" open><summary><section id="method.with_subscriber-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tracing/instrument.rs.html#169-177">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="fnname">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;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></span></span></span><span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="struct" href="struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>&gt;,</span></h4></section></summary><div class='docblock'>Attaches the provided <a href="trait.Subscriber.html"><code>Subscriber</code></a> to this type, returning a
<a href="instrument/struct.WithDispatch.html" title="WithDispatch"><code>WithDispatch</code></a> wrapper. <a href="instrument/trait.WithSubscriber.html#method.with_subscriber">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/tracing/instrument.rs.html#221-226">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="fnname">with_current_subscriber</a>(self) -&gt; <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;Self&gt;<span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a>&lt;T&gt;</span><code class="content"><span class="where fmt-newline">impl&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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;</span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></span></span></span></h4></section></summary><div class='docblock'>Attaches the current <a href="dispatcher/index.html#setting-the-default-subscriber">default</a> <a href="trait.Subscriber.html"><code>Subscriber</code></a> to this type, returning a
<a href="instrument/struct.WithDispatch.html" title="WithDispatch"><code>WithDispatch</code></a> wrapper. <a href="instrument/trait.WithSubscriber.html#method.with_current_subscriber">Read more</a></div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="tracing" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>