You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I used the salvo web framework, I found that the logs were always missing. Through debugging, I found that it was not a salvo problem, but a tracing problem.
#[derive(Debug)]
pub struct TraceLogger;
#[async_trait::async_trait]
impl Handler for TraceLogger {
async fn handle(&self, req: &mut Request, depot: &mut Depot, res: &mut Response, ctrl: &mut FlowCtrl) {
let trace = Uuid::new_v4().as_simple().to_string();
let traces = trace.clone();
let span = tracing::span!(Level::INFO, "", %trace);
depot.insert(REQUEST_ID_NAME, trace);
let url = format!("{}{}", req.remote_addr(), req.uri().path());
async move {
let now = Instant::now();
ctrl.call_next(req, depot, res).await;
let duration = now.elapsed();
let span = Span::current().clone();
let n = span.is_none();
let d = span.is_disabled();
let f = span.has_field("trace");
tracing::info!(url = %url, duration = ?duration, traces2 = traces, n = n, d = d, f = f);
}
.instrument(span)
.await
}
}
But printing logs sometimes loses trace=xxx information:
My local development environment (Windows 10: 19045.4291) will also appear, and online (Linux 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64 GNU/Linux) will also appear.
Description
Already mentioned above.
The text was updated successfully, but these errors were encountered:
immno
changed the title
tracing::span! missing fieldstracing::span! missing fieldsMay 22, 2024
I have been troubleshooting this issue until now. We used the tokio-cron-scheduler crate, which caused this problem. After we removed tokio-cron-scheduler, it finally worked properly without omissions and misalignment. Thanks to tracing, it works great!
Bug Report
When I used the
salvo
web framework, I found that the logs were always missing. Through debugging, I found that it was not a salvo problem, but atracing
problem.But printing logs sometimes loses
trace=xxx
information:I can't understand why it happens.
Version
Platform
My local development environment (
Windows 10: 19045.4291
) will also appear, and online (Linux 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64 GNU/Linux
) will also appear.Description
Already mentioned above.
The text was updated successfully, but these errors were encountered: