Skip to content
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

Setting trace and span id in logs. #119

Open
ShovelJockey opened this issue Mar 22, 2024 · 2 comments
Open

Setting trace and span id in logs. #119

ShovelJockey opened this issue Mar 22, 2024 · 2 comments

Comments

@ShovelJockey
Copy link

ShovelJockey commented Mar 22, 2024

I am attempting to implement otel tracing with axum, I found a hacky method that seemed to work for some span events like close but not for new with:

span.record("trace_id", tracing_id::find_trace_id_from_tracing(&span));

After creating the span, was hoping someone else might have a better method for getting this context into the logs, the traces themselves seem to be working well.

@ShovelJockey ShovelJockey changed the title trace_id is set only on FmtSpan::CLOSE not FmtSpan::NEW in logs Setting trace and span id in logs. Mar 22, 2024
@mladedav
Copy link
Contributor

Sorry, I don't understand what you're saying.

If you set up you subscriber/formatter to print span attributes, then all logs after that record call should have your trace_id printed in them. That said this seems more like a question about tracing itself rather than about tracing-opentelemetry?

It's true this crate could probably create something to make this easier on users so that you wouldn't have to resort to manually appending the trace ID.

@ShovelJockey
Copy link
Author

Apologies I am fairly new to setting up tracing, with many libraries working together its quite unclear where I should be trying to make these changes. Additionally trying to set ids in tracing seems to be an issue stumping alot of people from what I have seen from searching around.

Creating a custom formatter seems to be the best maybe, but so far seem to running into issues with this effecting the otlp exporter/pipeline.

Please close if this seems too off topic for this crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants