tracing-async2
This crate makes it easy to create your own custom tracing layers using a simple callback mechanism. One abvious use is to store tracing events into a database but you could just as well send them to a downstream service using gRPC or http. Or, for testing purposes, to accumulate them into a vector.
This crate provides a set of tracing layers that can be used to process
[tracing::Event
]s using simple callbacks or even in an asynchronous
context. This is done using variations the [CallbackLayer
].
Using callback_layer
If your needs are really simple, like accumulating traces in a vector.
Then you can use the [callback_layer
]:
use ;
use ;
use ;
let log = new;
let cb_log = log.clone;
registry
.with
.with
.init;
Using channel_layer
If you ever had the need to record traces in a database or do something
asynchronously with [tracing::Event
], then you can use the
[channel_layer
]:
use channel_layer;
use ;
use ;
let rt = new_current_thread
.build
.expect;
rt.block_on;
Using async_layer
If you don't want to handle the channel yourself, then you might consider
the use of [async_layer
] instead:
use async_layer;
use ;
use ;
let rt = new_current_thread
.build
.expect;
rt.block_on;
License: MIT