This tag should be used for the Rust tracing library and related crates.
Questions tagged [rust-tracing]
41 questions
1
vote
1 answer
How to conditionally call tracing-subscriber methods?
I'm trying to setup tracing and I have this code but it compiles with errors:
use tracing_subscriber;
pub fn init(is_pretty: bool) {
let subscriber = tracing_subscriber::fmt();
if is_pretty {
&subscriber.pretty();
}
…

Fred Hors
- 3,258
- 3
- 25
- 71
1
vote
1 answer
How to use thread local storage for tracing events?
This code uses tracing events:
# Cargo.toml
[dependencies]
tracing = "0.1.3"
tracing-subscriber = { version = "0.2.9", features = ["chrono", "env-filter", "fmt"] }
tracing-appender = "0.1.1"
use tracing::{Level, event, };
use…

Sarvi Shanmugham
- 487
- 4
- 13
0
votes
1 answer
how can I ignore certain attributes based on feature flag (without cfg_attr)?
My crate has a "tracing" feature. When it's turned on, I include dependencies tracing, tracing_subscriber, etc. When it's turned off, those dependencies are also turned off, which means that uses of functions/macros/attributes from those crates…

ajp
- 1,723
- 14
- 22
0
votes
0 answers
adding trace_id field to all emited logs using tokio tracing
Having trace_id field on all log events is common practice in distributed applications. This enables us to be able to follow logs for a specific request in the application.
I have an actix-web middleware that extracts a header from the http requests…

Farhad Farahi
- 35,528
- 7
- 73
- 70
0
votes
1 answer
control level of synthetic events from .with_span_events()?
I'm able to emit events using https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Layer.html#method.with_span_events, but they are created at TRACE level. Is there any way to cause these to be created at a different level?

ajp
- 1,723
- 14
- 22
0
votes
1 answer
Change tracing_subsciber's compact logger format
tracing_subscriber provides a compact format that looks like this:
DEBUG nh::nixos:51: out_dir: TempDir { path: "/tmp/nh-os-uC6E1T" }
DEBUG nh::nixos:52: out_link "/tmp/nh-os-uC6E1T/result"
INFO nh::commands:131: Building NixOS configuration
I…

viperML
- 21
- 1
0
votes
1 answer
How to transform a String into a Level to be used with tracing_subscriber?
I want to set the tracing Level using a String (because I get the Level from an env var).
let env_log_level = std::env::var("LOG_LEVEL").unwrap();
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG) // somehow use env_log_level…

miqrc
- 1,964
- 2
- 18
- 24
0
votes
0 answers
Rust thread stack overflow because of info! log macro
I am currently developing a little game in rust (I am a beginner). For this game I use threads to read and write on a TcpStream.
The whole project compile without errors.
I have use the macro "info!" everywhere in my project in order to debug…

Clément
- 53
- 6
0
votes
1 answer
Timing async functions in rust
I would like to time async function calls in Rust. The crate tracing_timing does not appear adequate since it does not support async function calls. What I would like is that after the end of the running of the program I obtain statistics over the…

Mathieu Dutour Sikiric
- 534
- 4
- 14
0
votes
1 answer
Getting parent span field values with tokio-tracing
I'm trying to instrument a function using tokio tracing, get its arguments and then walk to the parent span and get the values for a handful of fields. I was able to successfully get the argument by creating a new Layer as follows:
impl Layer…

Julio
- 2,261
- 4
- 30
- 56
0
votes
0 answers
Route some events to separate files while log everything else to default location with Rust tracing
I need to log events from some modules to separate log files while keep logging all other events to the default location. In Python, I would configure separate loggers with propagate=False and let root logger to handle everything else that is not…

Ivan Arbuzov
- 21
- 4