[−][src]Macro tokio_trace::span
Constructs a new span.
Examples
Creating a new span with no fields:
let span = span!(Level::TRACE, "my span"); span.enter(|| { // do work inside the span... });
Creating a span with fields:
span!(Level::TRACE, "my span", foo = 2, bar = "a string").enter(|| { // do work inside the span... });
Note that a trailing comma on the final field is valid:
span!( Level::TRACE, "my span", foo = 2, bar = "a string", );
Creating a span with custom target and log level:
span!( Level::TRACE, target: "app_span", "my span", foo = 3, bar = "another string" );
Field values may be recorded after the span is created:
let my_span = span!(Level::TRACE, "my span", foo = 2, bar); my_span.record("bar", &7);
Note that a span may have up to 32 fields. The following will not compile:
ⓘThis example deliberately fails to compile
span!( Level::TRACE, "too many fields!", a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8, i = 9, j = 10, k = 11, l = 12, m = 13, n = 14, o = 15, p = 16, q = 17, r = 18, s = 19, t = 20, u = 21, v = 22, w = 23, x = 24, y = 25, z = 26, aa = 27, bb = 28, cc = 29, dd = 30, ee = 31, ff = 32, gg = 33 );