-
Notifications
You must be signed in to change notification settings - Fork 726
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
Include Trace ID and Span ID in formatted logs #1481
Comments
FWIW, I started prototyping a sketch of an A recent |
Has anyone solved this? I am also interested in this as I use Grafana stack Loki and Tempo. I would really love to see the co-relation between logs and trace so that I can visualize things in better way. |
@kesavkolla I got it working with Grafana Tempo, I'll push my code later today and share. |
@kesavkolla this is some copy pasta but should be enough to get you started, https://gist.github.com/loriopatrick/bd00116562084b1d61f105f31d31afe0 |
Didn't work :-( couple of things function new_span is not part of Layer trait. There is no method to_hex in TraceId struct. I have fixed them but I didn't get any output on console log. |
Are there some news? The correlation of logs and traces in jaeger would be powerful.
I have also looked into #1304 of @hawkw but I couldn't get it to run with the Trace and Span IDs in the logs. I've tried many things the last days and the only logging (but not so nice) solution was the usage of the
It would be awesome if some experienced could help to get it to work. I guess it's just a small thing but I just couldn't figure it out. I'm not searching for a perfect solution, I just want to have the TraceID and SpanID in the json formatted log messages. I've prepared a small sample application you can use to try it, to not have the effort to bootstrap a sample application. You can just start jaeger with the script and run the application. Thanks in Advance! |
@cschaible I haven't looked into this myself but there appears to be a tracing-loki crate now: https://crates.io/crates/tracing-loki. You might be able to utilize that or fork it for you purposes. |
Thank you for the fast reply @loriopatrick! |
Hopefully fix tokio-rs#1481. Basically, this lets opentelemetry users associate logs with traces and spans.
One issue I've been thinking about is around this piece of functionality. When our team uses the |
Feature Request
Motivation
When using
tracing
to report traces to both a tracing backend such as Grafana Tempo and a logging backend such as Grafana Loki it is possible to link between the two using the span ID and trace ID. See for instance this example: https://grafana.com/blog/2020/11/09/trace-discovery-in-grafana-tempo-using-prometheus-exemplars-loki-2.0-queries-and-more/However, it doesn't look like it is possible to include the Span ID and Trace ID in the JSON logs produced using tracing-subscriber.
Proposal
This could take a variety of forms -- two thoughts (based on places that I looked):
tracing-subscriber
could include information to include the trace ID and span ID. This information may not be generally available, so it may not be feasible.tracing-opentelemetry
could provide an option that added the span and trace ID as fields to the spans and events passed to the later layers. This would allow thetracing-subscriber
to include them in the JSON logs since they would be just be additional fields.I'm not sure which of these would be the best approach, or if there are other approaches that would be better.
The text was updated successfully, but these errors were encountered: