520 lines
101 KiB
HTML
520 lines
101 KiB
HTML
<!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" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script src="../crates.js"></script><script defer src="../main.js"></script>
|
||
<noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu" role="button">☰</div><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">Struct Span</h2><div class="sidebar-elems"><div class="block items"><h3 class="sidebar-title"><a href="#implementations">Methods</a></h3><div class="sidebar-links"><a href="#method.child_of">child_of</a><a href="#method.current">current</a><a href="#method.enter">enter</a><a href="#method.entered">entered</a><a href="#method.field">field</a><a href="#method.follows_from">follows_from</a><a href="#method.has_field">has_field</a><a href="#method.id">id</a><a href="#method.in_scope">in_scope</a><a href="#method.is_disabled">is_disabled</a><a href="#method.is_none">is_none</a><a href="#method.metadata">metadata</a><a href="#method.new">new</a><a href="#method.new_disabled">new_disabled</a><a href="#method.new_root">new_root</a><a href="#method.none">none</a><a href="#method.or_current">or_current</a><a href="#method.record">record</a><a href="#method.record_all">record_all</a><a href="#method.with_subscriber">with_subscriber</a></div><h3 class="sidebar-title"><a href="#trait-implementations">Trait Implementations</a></h3><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Drop">Drop</a><a href="#impl-From%3C%26%27a%20Span%3E">From<&'a Span></a><a href="#impl-From%3CSpan%3E">From<Span></a><a href="#impl-Hash">Hash</a><a href="#impl-PartialEq%3CSpan%3E">PartialEq<Span></a></div><h3 class="sidebar-title"><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">!UnwindSafe</a></div><h3 class="sidebar-title"><a href="#blanket-implementations">Blanket Implementations</a></h3><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Instrument">Instrument</a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a><a href="#impl-WithSubscriber">WithSubscriber</a></div></div><h2 class="location">Other items in<br><a href="index.html">tracing</a></h2><div id="sidebar-vars" data-name="Span" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../tracing/index.html"><img src="https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png" alt="logo"></a><nav class="sub"><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><h1 class="fqn"><span class="in-band">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></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/tracing/span.rs.html#348-358" title="goto source code">[src]</a></span></h1><div class="docblock item-decl"><pre class="rust struct"><code>pub struct Span { /* fields omitted */ }</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><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#422-1359" title="goto source code">[src]</a></div><a href="#impl" class="anchor"></a><h3 class="code-header in-band">impl <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.new" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#436-438" title="goto source code">[src]</a></div><a href="#method.new" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>(meta: &'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a><'static>, values: &<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a><'_>) -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></summary><div class="docblock"><p>Constructs a new <code>Span</code> with the given <a href="../metadata">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="../subscriber/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><div id="method.new_root" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#460-462" title="goto source code">[src]</a></div><a href="#method.new_root" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.new_root" class="fnname">new_root</a>(meta: &'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a><'static>, values: &<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a><'_>) -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></summary><div class="docblock"><p>Constructs a new <code>Span</code> as the root of its own trace tree, with the
|
||
given <a href="../metadata">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><div id="method.child_of" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#484-493" title="goto source code">[src]</a></div><a href="#method.child_of" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.child_of" class="fnname">child_of</a>(<br> parent: impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>>>, <br> meta: &'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a><'static>, <br> values: &<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a><'_><br>) -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></summary><div class="docblock"><p>Constructs a new <code>Span</code> as child of the given parent span, with the
|
||
given <a href="../metadata">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><div id="method.new_disabled" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#519-524" title="goto source code">[src]</a></div><a href="#method.new_disabled" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.new_disabled" class="fnname">new_disabled</a>(meta: &'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a><'static>) -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></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><div id="method.none" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#533-538" title="goto source code">[src]</a></div><a href="#method.none" class="anchor"></a><h4 class="code-header">pub const fn <a href="#method.none" class="fnname">none</a>() -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></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<Span></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><div id="method.current" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#548-560" title="goto source code">[src]</a></div><a href="#method.current" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.current" class="fnname">current</a>() -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></summary><div class="docblock"><p>Returns a handle to the span <a href="../subscriber/trait.Subscriber.html#method.current">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><div id="method.enter" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#775-778" title="goto source code">[src]</a></div><a href="#method.enter" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.enter" class="fnname">enter</a>(&self) -> <a class="struct" href="span/struct.Entered.html" title="struct tracing::span::Entered">Entered</a><'_></h4></div></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" class="section-header"><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</span> <span class="kw">fn</span> <span class="ident">my_async_function</span>() {
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"my_async_function"</span>);
|
||
|
||
<span class="comment">// THIS WILL RESULT IN INCORRECT TRACES</span>
|
||
<span class="kw">let</span> <span class="ident">_enter</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">enter</span>();
|
||
<span class="ident">some_other_async_function</span>().<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="#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</span> <span class="kw">fn</span> <span class="ident">my_async_function</span>() {
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"my_async_function"</span>);
|
||
|
||
<span class="kw">let</span> <span class="ident">some_value</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">in_scope</span>(<span class="op">|</span><span class="op">|</span> {
|
||
<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</span>
|
||
<span class="comment">// the await point.</span>
|
||
<span class="ident">some_other_async_function</span>(<span class="ident">some_value</span>).<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="https://docs.rs/tracing/latest/tracing/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='information'><div class='tooltip ignore'>ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore"><code><span class="kw">use</span> <span class="ident">tracing::Instrument</span>;
|
||
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">my_async_function</span>() {
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"my_async_function"</span>);
|
||
<span class="kw">async</span> <span class="kw">move</span> {
|
||
<span class="comment">// This is correct! If we yield here, the span will be exited,</span>
|
||
<span class="comment">// and re-entered when we resume.</span>
|
||
<span class="ident">some_other_async_function</span>().<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>
|
||
.<span class="ident">instrument</span>(<span class="ident">span</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='information'><div class='tooltip ignore'>ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore"><code><span class="kw">use</span> <span class="ident">tracing::Instrument</span>;
|
||
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">my_async_function</span>() {
|
||
<span class="kw">let</span> <span class="ident">some_value</span> <span class="op">=</span> <span class="ident">some_other_async_function</span>()
|
||
.<span class="ident">instrument</span>(<span class="macro">debug_span!</span>(<span class="string">"some_other_async_function"</span>))
|
||
.<span class="kw">await</span>;
|
||
|
||
<span class="comment">// ...</span>
|
||
}</code></pre></div>
|
||
</li>
|
||
<li>
|
||
<p>The <a href="../../attr.instrument.html"><code>#[instrument]</code> attribute macro</a> can automatically generate
|
||
correct code when used on an async function:</p>
|
||
|
||
<div class='information'><div class='tooltip ignore'>ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered ignore"><code><span class="attribute">#[<span class="ident">tracing::instrument</span>(<span class="ident">level</span> <span class="op">=</span> <span class="string">"info"</span>)]</span>
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">my_async_function</span>() {
|
||
|
||
<span class="comment">// This is correct! If we yield here, the span will be exited,</span>
|
||
<span class="comment">// and re-entered when we resume.</span>
|
||
<span class="ident">some_other_async_function</span>().<span class="kw">await</span>;
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
}</code></pre></div>
|
||
</li>
|
||
</ul>
|
||
<h5 id="examples" class="section-header"><a href="#examples">Examples</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::INFO</span>, <span class="string">"my_span"</span>);
|
||
<span class="kw">let</span> <span class="ident">guard</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">enter</span>();
|
||
|
||
<span class="comment">// code here is within the span</span>
|
||
|
||
<span class="ident">drop</span>(<span class="ident">guard</span>);
|
||
|
||
<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> <span class="ident">my_function</span>() -> <span class="ident">String</span> {
|
||
<span class="comment">// enter a span for the duration of this function.</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">trace_span!</span>(<span class="string">"my_function"</span>);
|
||
<span class="kw">let</span> <span class="ident">_enter</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">enter</span>();
|
||
|
||
<span class="comment">// anything happening in functions we call is still inside the span...</span>
|
||
<span class="ident">my_other_function</span>();
|
||
|
||
<span class="comment">// returning from the function drops the guard, exiting the span.</span>
|
||
<span class="kw">return</span> <span class="string">"Hello world"</span>.<span class="ident">to_owned</span>();
|
||
}
|
||
|
||
<span class="kw">fn</span> <span class="ident">my_other_function</span>() {
|
||
<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 class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"my_great_span"</span>);
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="ident">_enter</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">enter</span>();
|
||
|
||
<span class="comment">// this event occurs inside the span.</span>
|
||
<span class="macro">info!</span>(<span class="string">"i'm in the span!"</span>);
|
||
|
||
<span class="comment">// exiting the scope drops the guard, exiting the span.</span>
|
||
}
|
||
|
||
<span class="comment">// this event is not inside the span.</span>
|
||
<span class="macro">info!</span>(<span class="string">"i'm outside the span!"</span>)</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.entered" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#886-892" title="goto source code">[src]</a></div><a href="#method.entered" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.entered" class="fnname">entered</a>(self) -> <a class="struct" href="span/struct.EnteredSpan.html" title="struct tracing::span::EnteredSpan">EnteredSpan</a></h4></div></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 class="ident">_span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"something_interesting"</span>).<span class="ident">entered</span>();</code></pre></div>
|
||
<p>rather than:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"something_interesting"</span>);
|
||
<span class="kw">let</span> <span class="ident">_e</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">enter</span>();</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" class="section-header"><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 class="ident">span</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::INFO</span>, <span class="string">"doing_something"</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// code here is within the span</span>
|
||
|
||
<span class="comment">// explicitly exit the span, returning it</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">exit</span>();
|
||
|
||
<span class="comment">// code here is no longer within the span</span>
|
||
|
||
<span class="comment">// enter the span again</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">entered</span>();
|
||
|
||
<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> <span class="ident">my_function</span>() -> <span class="ident">String</span> {
|
||
<span class="comment">// enter a span for the duration of this function.</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">trace_span!</span>(<span class="string">"my_function"</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// anything happening in functions we call is still inside the span...</span>
|
||
<span class="ident">my_other_function</span>();
|
||
|
||
<span class="comment">// returning from the function drops the guard, exiting the span.</span>
|
||
<span class="kw">return</span> <span class="string">"Hello world"</span>.<span class="ident">to_owned</span>();
|
||
}
|
||
|
||
<span class="kw">fn</span> <span class="ident">my_other_function</span>() {
|
||
<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> <span class="ident">tracing::field</span>;
|
||
|
||
<span class="comment">// create the span with an empty field, and enter it.</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"my_span"</span>, <span class="ident">some_field</span> <span class="op">=</span> <span class="ident">field::Empty</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// we can still record a value for the field while the span is entered.</span>
|
||
<span class="ident">span</span>.<span class="ident">record</span>(<span class="string">"some_field"</span>, <span class="kw-2">&</span><span class="string">"hello world!"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.or_current" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1017-1022" title="goto source code">[src]</a></div><a href="#method.or_current" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.or_current" class="fnname">or_current</a>(self) -> Self</h4></div></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/1.59.0/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> <span class="ident">_parent_span</span> <span class="op">=</span> <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
<span class="kw">let</span> <span class="ident">child_span</span> <span class="op">=</span> <span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>);
|
||
|
||
<span class="ident">std::thread::spawn</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> {
|
||
<span class="kw">let</span> <span class="ident">_entered</span> <span class="op">=</span> <span class="ident">child_span</span>.<span class="ident">entered</span>();
|
||
|
||
<span class="macro">tracing::info!</span>(<span class="string">"spawned a thread!"</span>);
|
||
|
||
<span class="comment">// ...</span>
|
||
});</code></pre></div>
|
||
<p>If the current <a href="trait.Subscriber.html"><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> <span class="ident">_parent_span</span> <span class="op">=</span> <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
<span class="comment">// If DEBUG is enabled, then "child" will be enabled, and `or_current`</span>
|
||
<span class="comment">// returns "child". Otherwise, if DEBUG is not enabled, "child" will be</span>
|
||
<span class="comment">// disabled, and `or_current` returns "parent".</span>
|
||
<span class="kw">let</span> <span class="ident">child_span</span> <span class="op">=</span> <span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>).<span class="ident">or_current</span>();
|
||
|
||
<span class="ident">std::thread::spawn</span>(<span class="kw">move</span> <span class="op">|</span><span class="op">|</span> {
|
||
<span class="kw">let</span> <span class="ident">_entered</span> <span class="op">=</span> <span class="ident">child_span</span>.<span class="ident">entered</span>();
|
||
|
||
<span class="macro">tracing::info!</span>(<span class="string">"spawned a thread!"</span>);
|
||
|
||
<span class="comment">// ...</span>
|
||
});</code></pre></div>
|
||
<p>When spawning <a href="https://doc.rust-lang.org/1.59.0/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> <span class="ident">tracing::Instrument</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">_parent_span</span> <span class="op">=</span> <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
<span class="kw">let</span> <span class="ident">child_span</span> <span class="op">=</span> <span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>);
|
||
|
||
<span class="ident">tokio::spawn</span>(
|
||
<span class="kw">async</span> {
|
||
<span class="macro">tracing::info!</span>(<span class="string">"spawned a task!"</span>);
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
}.<span class="ident">instrument</span>(<span class="ident">child_span</span>.<span class="ident">or_current</span>())
|
||
);</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> <span class="ident">tracing::Instrument</span>;
|
||
<span class="kw">async</span> <span class="kw">fn</span> <span class="ident">my_async_fn</span>() {
|
||
<span class="comment">// ...</span>
|
||
}
|
||
|
||
<span class="kw">let</span> <span class="ident">_parent_span</span> <span class="op">=</span> <span class="macro">tracing::info_span!</span>(<span class="string">"parent"</span>).<span class="ident">entered</span>();
|
||
|
||
<span class="comment">// Do this:</span>
|
||
<span class="ident">tokio::spawn</span>(
|
||
<span class="ident">my_async_fn</span>().<span class="ident">instrument</span>(<span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>).<span class="ident">or_current</span>())
|
||
);
|
||
|
||
<span class="comment">// ...rather than this:</span>
|
||
<span class="ident">tokio::spawn</span>(
|
||
<span class="ident">my_async_fn</span>()
|
||
.<span class="ident">instrument</span>(<span class="macro">tracing::debug_span!</span>(<span class="string">"child"</span>))
|
||
.<span class="ident">in_current_span</span>()
|
||
);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.in_scope" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1090-1093" title="goto source code">[src]</a></div><a href="#method.in_scope" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.in_scope" class="fnname">in_scope</a><F: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> T, T>(&self, f: F) -> T</h4></div></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" class="section-header"><a href="#examples-2">Examples</a></h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">my_span</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::TRACE</span>, <span class="string">"my_span"</span>);
|
||
|
||
<span class="ident">my_span</span>.<span class="ident">in_scope</span>(<span class="op">|</span><span class="op">|</span> {
|
||
<span class="comment">// this event occurs within the span.</span>
|
||
<span class="macro">trace!</span>(<span class="string">"i'm in the span!"</span>);
|
||
});
|
||
|
||
<span class="comment">// this event occurs outside the span.</span>
|
||
<span class="macro">trace!</span>(<span class="string">"i'm not in the span!"</span>);</code></pre></div>
|
||
<p>Calling a function and returning the result:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn</span> <span class="ident">hello_world</span>() -> <span class="ident">String</span> {
|
||
<span class="string">"Hello world!"</span>.<span class="ident">to_owned</span>()
|
||
}
|
||
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"hello_world"</span>);
|
||
<span class="comment">// the span will be entered for the duration of the call to</span>
|
||
<span class="comment">// `hello_world`.</span>
|
||
<span class="kw">let</span> <span class="ident">a_string</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">in_scope</span>(<span class="ident">hello_world</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1097-1102" title="goto source code">[src]</a></div><a href="#method.field" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.field" class="fnname">field</a><Q: ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&self, field: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Q) -> <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="field/struct.Field.html" title="struct tracing::field::Field">Field</a>> <span class="where fmt-newline">where<br> Q: <a class="trait" href="field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a>, </span></h4></div></summary><div class="docblock"><p>Returns a <a href="../field/struct.Field.html"><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><div id="method.has_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1107-1112" title="goto source code">[src]</a></div><a href="#method.has_field" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.has_field" class="fnname">has_field</a><Q: ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&self, field: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Q) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.bool.html">bool</a> <span class="where fmt-newline">where<br> Q: <a class="trait" href="field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a>, </span></h4></div></summary><div class="docblock"><p>Returns true if this <code>Span</code> has a field for the given
|
||
<a href="../field/struct.Field.html"><code>Field</code></a> or field name.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.record" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1184-1200" title="goto source code">[src]</a></div><a href="#method.record" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.record" class="fnname">record</a><Q: ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V>(&self, field: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Q, value: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>V) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Self <span class="where fmt-newline">where<br> Q: <a class="trait" href="field/trait.AsField.html" title="trait tracing::field::AsField">AsField</a>,<br> V: <a class="trait" href="trait.Value.html" title="trait tracing::Value">Value</a>, </span></h4></div></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> <span class="ident">tracing</span>::{<span class="ident">trace_span</span>, <span class="ident">field</span>};
|
||
|
||
<span class="comment">// Create a span with two fields: `greeting`, with the value "hello world", and</span>
|
||
<span class="comment">// `parting`, without a value.</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">trace_span!</span>(<span class="string">"my_span"</span>, <span class="ident">greeting</span> <span class="op">=</span> <span class="string">"hello world"</span>, <span class="ident">parting</span> <span class="op">=</span> <span class="ident">field::Empty</span>);
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
<span class="comment">// Now, record a value for parting as well.</span>
|
||
<span class="comment">// (note that the field name is passed as a string slice)</span>
|
||
<span class="ident">span</span>.<span class="ident">record</span>(<span class="string">"parting"</span>, <span class="kw-2">&</span><span class="string">"goodbye world!"</span>);</code></pre></div>
|
||
<p>However, it may also be used to record a <em>new</em> value for a field whose
|
||
value was already recorded:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">tracing::info_span</span>;
|
||
|
||
<span class="comment">// Initially, let's assume that our attempt to do something is going okay...</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">info_span!</span>(<span class="string">"doing_something"</span>, <span class="ident">is_okay</span> <span class="op">=</span> <span class="bool-val">true</span>);
|
||
<span class="kw">let</span> <span class="ident">_e</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">enter</span>();
|
||
|
||
<span class="kw">match</span> <span class="ident">do_something</span>() {
|
||
<span class="prelude-val">Ok</span>(<span class="ident">something</span>) => {
|
||
<span class="comment">// ...</span>
|
||
}
|
||
<span class="prelude-val">Err</span>(<span class="kw">_</span>) => {
|
||
<span class="comment">// Things are no longer okay!</span>
|
||
<span class="ident">span</span>.<span class="ident">record</span>(<span class="string">"is_okay"</span>, <span class="kw-2">&</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> <span class="ident">tracing</span>::{<span class="ident">trace_span</span>, <span class="ident">field</span>};
|
||
|
||
<span class="comment">// Create a span with two fields: `greeting`, with the value "hello world", and</span>
|
||
<span class="comment">// `parting`, without a value.</span>
|
||
<span class="kw">let</span> <span class="ident">span</span> <span class="op">=</span> <span class="macro">trace_span!</span>(<span class="string">"my_span"</span>, <span class="ident">greeting</span> <span class="op">=</span> <span class="string">"hello world"</span>, <span class="ident">parting</span> <span class="op">=</span> <span class="ident">field::Empty</span>);
|
||
|
||
<span class="comment">// ...</span>
|
||
|
||
<span class="comment">// Now, you try to record a value for a new field, `new_field`, which was not</span>
|
||
<span class="comment">// declared as `Empty` or populated when you created `span`.</span>
|
||
<span class="comment">// You won't get any error, but the assignment will have no effect!</span>
|
||
<span class="ident">span</span>.<span class="ident">record</span>(<span class="string">"new_field"</span>, <span class="kw-2">&</span><span class="string">"interesting_value_you_really_need"</span>);
|
||
|
||
<span class="comment">// Instead, all fields that may be recorded after span creation should be declared up front,</span>
|
||
<span class="comment">// using field::Empty when a value is not known, as we did for `parting`.</span>
|
||
<span class="comment">// This `record` call will indeed replace field::Empty with "you will be remembered".</span>
|
||
<span class="ident">span</span>.<span class="ident">record</span>(<span class="string">"parting"</span>, <span class="kw-2">&</span><span class="string">"you will be remembered"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.record_all" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1203-1221" title="goto source code">[src]</a></div><a href="#method.record_all" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.record_all" class="fnname">record_all</a>(&self, values: &<a class="struct" href="field/struct.ValueSet.html" title="struct tracing::field::ValueSet">ValueSet</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Self</h4></div></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><div id="method.is_disabled" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1230-1232" title="goto source code">[src]</a></div><a href="#method.is_disabled" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.is_disabled" class="fnname">is_disabled</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.bool.html">bool</a></h4></div></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="#method.is_none"><code>is_none</code></a>.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.is_none" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1245-1247" title="goto source code">[src]</a></div><a href="#method.is_none" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.is_none" class="fnname">is_none</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.bool.html">bool</a></h4></div></summary><div class="docblock"><p>Returns <code>true</code> if this span was constructed by <a href="#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="#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><div id="method.follows_from" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1296-1303" title="goto source code">[src]</a></div><a href="#method.follows_from" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.follows_from" class="fnname">follows_from</a>(&self, from: impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>>>) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Self</h4></div></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" class="section-header"><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> <span class="ident">span1</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::INFO</span>, <span class="string">"span_1"</span>);
|
||
<span class="kw">let</span> <span class="ident">span2</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::DEBUG</span>, <span class="string">"span_2"</span>);
|
||
<span class="ident">span2</span>.<span class="ident">follows_from</span>(<span class="ident">span1</span>);</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 class="ident">span</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::INFO</span>, <span class="string">"hello!"</span>);
|
||
<span class="ident">span</span>.<span class="ident">follows_from</span>(<span class="ident">Span::current</span>());</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 class="ident">span</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::INFO</span>, <span class="string">"hello!"</span>);
|
||
<span class="kw">let</span> <span class="ident">curr</span> <span class="op">=</span> <span class="ident">Span::current</span>();
|
||
<span class="ident">span</span>.<span class="ident">follows_from</span>(<span class="kw-2">&</span><span class="ident">curr</span>);</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 class="ident">span</span> <span class="op">=</span> <span class="macro">span!</span>(<span class="ident">Level::INFO</span>, <span class="string">"hello!"</span>);
|
||
<span class="kw">let</span> <span class="ident">id</span> <span class="op">=</span> <span class="ident">span</span>.<span class="ident">id</span>();
|
||
<span class="ident">span</span>.<span class="ident">follows_from</span>(<span class="ident">id</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.id" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1306-1308" title="goto source code">[src]</a></div><a href="#method.id" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.id" class="fnname">id</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>></h4></div></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><div id="method.metadata" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1311-1313" title="goto source code">[src]</a></div><a href="#method.metadata" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.metadata" class="fnname">metadata</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&'static <a class="struct" href="struct.Metadata.html" title="struct tracing::Metadata">Metadata</a><'static>></h4></div></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><div id="method.with_subscriber" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1354-1358" title="goto source code">[src]</a></div><a href="#method.with_subscriber" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.with_subscriber" class="fnname">with_subscriber</a><T>(<br> &self, <br> f: impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.tuple.html">(</a>&<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>, &<a class="struct" href="struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a><a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.tuple.html">)</a>) -> T<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T></h4></div></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><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><div id="impl-Clone" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#347" title="goto source code">[src]</a></div><a href="#impl-Clone" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.clone" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#347" title="goto source code">[src]</a></div><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h4></div></summary><div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.59.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.clone_from" class="method trait-impl has-srclink"><div 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/1.59.0/src/core/clone.rs.html#130" title="goto source code">[src]</a></div><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Self)</h4></div></summary><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.59.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Debug" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1378-1409" title="goto source code">[src]</a></div><a href="#impl-Debug" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.fmt" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1379-1408" title="goto source code">[src]</a></div><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.59.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></div></summary><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.59.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Drop" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1441-1462" title="goto source code">[src]</a></div><a href="#impl-Drop" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.drop" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1443-1461" title="goto source code">[src]</a></div><a href="#method.drop" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/ops/drop/trait.Drop.html#tymethod.drop" class="fnname">drop</a>(&mut self)</h4></div></summary><div class='docblock'><p>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.59.0/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-From%3C%26%27a%20Span%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1411-1415" title="goto source code">[src]</a></div><a href="#impl-From%3C%26%27a%20Span%3E" class="anchor"></a><h3 class="code-header in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><&'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>> for <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&'a <a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.from" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1412-1414" title="goto source code">[src]</a></div><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(span: &'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>) -> Self</h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-From%3C%26%27a%20Span%3E-1" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1417-1421" title="goto source code">[src]</a></div><a href="#impl-From%3C%26%27a%20Span%3E-1" class="anchor"></a><h3 class="code-header in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><&'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>> for <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.from-1" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1418-1420" title="goto source code">[src]</a></div><a href="#method.from-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(span: &'a <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>) -> Self</h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-From%3CSpan%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1423-1427" title="goto source code">[src]</a></div><a href="#impl-From%3CSpan%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>> for <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="span/struct.Id.html" title="struct tracing::span::Id">Id</a>></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.from-2" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1424-1426" title="goto source code">[src]</a></div><a href="#method.from-2" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/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>) -> Self</h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Hash" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1372-1376" title="goto source code">[src]</a></div><a href="#impl-Hash" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.hash" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1373-1375" title="goto source code">[src]</a></div><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hash.html#tymethod.hash" class="fnname">hash</a><H: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>>(&self, hasher: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&mut </a>H)</h4></div></summary><div class='docblock'><p>Feeds this value into the given <a href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hash.html#tymethod.hash">Read more</a></p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.hash_slice" class="method trait-impl has-srclink"><div 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/1.59.0/src/core/hash/mod.rs.html#237-239" title="goto source code">[src]</a></div><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a><H>(data: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.slice.html">&[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&mut </a>H) <span class="where fmt-newline">where<br> H: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>, </span></h4></div></summary><div class='docblock'><p>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.59.0/core/hash/trait.Hash.html#method.hash_slice">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-PartialEq%3CSpan%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1361-1370" title="goto source code">[src]</a></div><a href="#impl-PartialEq%3CSpan%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a>> for <a class="struct" href="struct.Span.html" title="struct tracing::Span">Span</a></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.eq" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/span.rs.html#1362-1369" title="goto source code">[src]</a></div><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Self) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.bool.html">bool</a></h4></div></summary><div class='docblock'><p>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/1.59.0/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.ne" class="method trait-impl has-srclink"><div 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/1.59.0/src/core/cmp.rs.html#219" title="goto source code">[src]</a></div><a href="#method.ne" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.59.0/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.bool.html">bool</a></h4></div></summary><div class='docblock'><p>This method tests for <code>!=</code>.</p>
|
||
</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"><div id="impl-RefUnwindSafe" class="impl has-srclink"><div class="rightside"></div><a href="#impl-RefUnwindSafe" class="anchor"></a><h3 class="code-header in-band">impl !<a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div><div id="impl-Send" class="impl has-srclink"><div class="rightside"></div><a href="#impl-Send" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div><div id="impl-Sync" class="impl has-srclink"><div class="rightside"></div><a href="#impl-Sync" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div><div id="impl-Unpin" class="impl has-srclink"><div class="rightside"></div><a href="#impl-Unpin" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div><div id="impl-UnwindSafe" class="impl has-srclink"><div class="rightside"></div><a href="#impl-UnwindSafe" class="anchor"></a><h3 class="code-header in-band">impl !<a class="trait" href="https://doc.rust-lang.org/1.59.0/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></div></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" open><summary><div id="impl-Any" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/any.rs.html#132-136" title="goto source code">[src]</a></div><a href="#impl-Any" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.type_id" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/any.rs.html#133" title="goto source code">[src]</a></div><a href="#method.type_id" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.59.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></div></summary><div class='docblock'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.59.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Borrow%3CT%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/borrow.rs.html#209-214" title="goto source code">[src]</a></div><a href="#impl-Borrow%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.borrow" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/borrow.rs.html#211" title="goto source code">[src]</a></div><a href="#method.borrow" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&</a>T</h4></div></summary><div class='docblock'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.59.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-BorrowMut%3CT%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/borrow.rs.html#218-222" title="goto source code">[src]</a></div><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.borrow_mut" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/borrow.rs.html#219" title="goto source code">[src]</a></div><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&mut </a>T</h4></div></summary><div class='docblock'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.59.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-From%3CT%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#550-554" title="goto source code">[src]</a></div><a href="#impl-From%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.from-3" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#551" title="goto source code">[src]</a></div><a href="#method.from-3" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Instrument" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/instrument.rs.html#276" title="goto source code">[src]</a></div><a href="#impl-Instrument" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="trait.Instrument.html" title="trait tracing::Instrument">Instrument</a> for T</h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.instrument" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/instrument.rs.html#82-84" title="goto source code">[src]</a></div><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>) -> <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a><Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><div class="notable">Notable traits for <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a><T></div><code class="content"><span class="where fmt-newline">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></h4></div></summary><div class='docblock'><p>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></p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.in_current_span" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/instrument.rs.html#121-123" title="goto source code">[src]</a></div><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) -> <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a><Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><div class="notable">Notable traits for <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a><T></div><code class="content"><span class="where fmt-newline">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="instrument/struct.Instrumented.html" title="struct tracing::instrument::Instrumented">Instrumented</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></h4></div></summary><div class='docblock'><p>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></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-Into%3CU%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#538-545" title="goto source code">[src]</a></div><a href="#impl-Into%3CU%3E" class="anchor"></a><h3 class="code-header in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.into" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#542" title="goto source code">[src]</a></div><a href="#method.into" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-ToOwned" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/alloc/borrow.rs.html#84-96" title="goto source code">[src]</a></div><a href="#impl-ToOwned" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.59.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Owned" class="type trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.59.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></div></summary><div class='docblock'><p>The resulting type after obtaining ownership.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.to_owned" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/alloc/borrow.rs.html#89" title="goto source code">[src]</a></div><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</h4></div></summary><div class='docblock'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.59.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.clone_into" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/alloc/borrow.rs.html#93" title="goto source code">[src]</a></div><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.reference.html">&mut </a>T)</h4></div></summary><div class="item-info"><div class="stab unstable"><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code> <a href="https://github.com/tokio-rs/tracing/issues/41263">#41263</a>)</div></div><div class='docblock'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.59.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-TryFrom%3CU%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#588-597" title="goto source code">[src]</a></div><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><h3 class="code-header in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error-1" class="type trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></div></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.try_from" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#594" title="goto source code">[src]</a></div><a href="#method.try_from" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-TryInto%3CU%3E" class="impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#574-583" title="goto source code">[src]</a></div><a href="#impl-TryInto%3CU%3E" class="anchor"></a><h3 class="code-header in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></h3></div></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="type trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></div></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.try_into" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="https://doc.rust-lang.org/1.59.0/src/core/convert/mod.rs.html#580" title="goto source code">[src]</a></div><a href="#method.try_into" class="anchor"></a><h4 class="code-header">pub fn <a href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.59.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></div></summary><div class='docblock'><p>Performs the conversion.</p>
|
||
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><div id="impl-WithSubscriber" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/instrument.rs.html#334" title="goto source code">[src]</a></div><a href="#impl-WithSubscriber" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="instrument/trait.WithSubscriber.html" title="trait tracing::instrument::WithSubscriber">WithSubscriber</a> for T</h3></div></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><div id="method.with_subscriber-1" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/instrument.rs.html#169-177" title="goto source code">[src]</a></div><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><S>(self, subscriber: S) -> <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a><Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><div class="notable">Notable traits for <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a><T></div><code class="content"><span class="where fmt-newline">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span> <span class="where fmt-newline">where<br> S: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="struct.Dispatch.html" title="struct tracing::Dispatch">Dispatch</a>>, </span></h4></div></summary><div class='docblock'><p>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></p>
|
||
</div></details><details class="rustdoc-toggle method-toggle" open><summary><div id="method.with_current_subscriber" class="method trait-impl has-srclink"><div class="rightside"><a class="srclink" href="../src/tracing/instrument.rs.html#221-226" title="goto source code">[src]</a></div><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) -> <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a><Self><span class="notable-traits"><span class="notable-traits-tooltip">ⓘ<div class="notable-traits-tooltiptext"><span class="docblock"><div class="notable">Notable traits for <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a><T></div><code class="content"><span class="where fmt-newline">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>> <a class="trait" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="struct" href="instrument/struct.WithDispatch.html" title="struct tracing::instrument::WithDispatch">WithDispatch</a><T></span><span class="where fmt-newline"> type <a href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" class="associatedtype">Output</a> = T::<a class="associatedtype" href="https://doc.rust-lang.org/1.59.0/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>;</span></code></span></div></span></span></h4></div></summary><div class='docblock'><p>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></p>
|
||
</div></details></div></details></div></section><section id="search" class="content hidden"></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.59.0 (9d1b2106e 2022-02-23)" ></div>
|
||
</body></html> |