Expand description
Substrate tracing primitives and macros.
To trace functions or individual code in Substrate, this crate provides within_span
and enter_span
. See the individual docs for how to use these macros.
Note that to allow traces from wasm execution environment there are
2 reserved identifiers for tracing Field
recording, stored in the consts:
WASM_TARGET_KEY
and WASM_NAME_KEY
- if you choose to record fields, you
must ensure that your identifiers do not clash with either of these.
Additionally, we have a const: WASM_TRACE_IDENTIFIER
, which holds a span name used
to signal that the ‘actual’ span name and target should be retrieved instead from
the associated Fields mentioned above.
Note: The tracing
crate requires trace metadata to be static. This does not work
for wasm code in substrate, as it is regularly updated with new code from on-chain
events. The workaround for this is for the wasm tracing wrappers to put the
name
and target
data in the values
map (normally they would be in the static
metadata assembled at compile time).
Re-exports§
pub use tracing;
pub use tracing_subscriber;
Modules§
- event
- Events represent single points in time during the execution of a program.
- span
- Spans represent periods of time in which a program was executing in a particular context.
Macros§
- debug
- Constructs an event at the debug level.
- debug_
span - Constructs a span at the debug level.
- enter_
span - Enter a span.
- error
- Constructs an event at the error level.
- error_
span - Constructs a span at the error level.
- event
- Constructs a new
Event
. - info
- Constructs an event at the info level.
- info_
span - Constructs a span at the info level.
- span
- Constructs a new span.
- trace
- Constructs an event at the trace level.
- trace_
span - Constructs a span at the trace level.
- warn
- Constructs an event at the warn level.
- warn_
span - Constructs a span at the warn level.
- within_
span - Runs given code within a tracing span, measuring it’s execution time.
Structs§
- Level
- Describes the level of verbosity of a span or event.
- Span
- A handle representing a span, with the capability to enter the span if it exists.
- Wasm
Entry Attributes - Span or Event Attributes
- Wasm
Field Name - The name of a field provided as the argument name when constructing an
event!
orspan!
. Generally generated automatically viastringify
from an'static &str
. Likely print-able. - Wasm
Fields - A list of
WasmFieldName
s in the order provided - Wasm
Metadata - Metadata provides generic information about the specific location of the
span!
orevent!
call on the wasm-side. - Wasm
Values Set - A list of
WasmFieldName
s with the givenWasmValue
(if provided) in the order specified.
Enums§
- Wasm
Level - The Tracing Level – the user can filter by this
- Wasm
Value - A parameter value provided to the span/event
Statics§
- WASM_
NAME_ KEY - The fieldname for the wasm-originated name
- WASM_
TARGET_ KEY - The fieldname for the wasm-originated target
- WASM_
TRACE_ IDENTIFIER - The identifier we are using to inject the wasm events in the generic
tracing
system
Functions§
- init_
for_ tests - Init a tracing subscriber for logging in tests.
- try_
init_ simple - Try to init a simple tracing subscriber with log compatibility layer.