-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to get properties that has been attached to the span? #11
Comments
No, logs are added to the spans. You should use struct Logger;
impl log::Log for Logger {
fn log(&self, record: &log::Record<'_>) {
Event::add_to_local_parent("log", || {
// ...
if let Some(message) = record.args().as_str() {
properties.push(("message", message).into());
} else {
properties.push(("message", record.args().to_string()).into());
}
// ...
let mut visitor = KwWriter(&mut properties); // your visitor
record.key_values().visit(&mut visitor).expect("visit should not fail");
properties
})
}
} Also, see |
Yes, I read this example, but I want someting opposite. For example, I want to get the identifier of the current span and add it to the log record, so I can link the logs to this span. |
To directly correlate logs and traces use |
@alekseysidorov I see. Logging alongside a
As an alternative, I suggest:
Additionally, we could explore outputting the logs in a structured of the trace spans: |
In the
tracing
crate, the log formatter can use span records to append them to the log output. This is useful for structured context logging.Since the
log
crate has already stabilized thekv
feature, there is an opportunity to implementtracing
contextual structured logging on top of thefastrace
andlog
combination.But it need to expose the record attached to the span. As I understand, in this library such kind of records named properties. So can I get them from
Span
?The text was updated successfully, but these errors were encountered: