Skip to content

[Bug]: traceId not correctly set for logs when using set_parent with opentelemetry-appender-tracing #2824

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

Open
Junochiu opened this issue Mar 18, 2025 · 0 comments · May be fixed by #2924
Open
Labels
bug Something isn't working triage:todo Needs to be traiged.

Comments

@Junochiu
Copy link

Junochiu commented Mar 18, 2025

What happened?

I'm using the tracing crate, tracing_opentelemetry, opentelemetry crates along with opentelemetry-appender-tracing (with experimental_use_tracing_span_context enabled). And noticed an issue when creating a new span and then calling set_parent, the logs exported will have the old traceId created with span! instead of the traceId from parent_context set with set_parent.

let span = span!(Level::INFO, SPAN_NAME);
span.set_parent(parent_context);
let _enter = span.enter();

// the following logging will have the trace ID created from `span!` instead of the parent_context
// when exporting with `opentelemetry-appender-tracing`
tracing::info!("next message in nats");
// if printing span.context().span().span_context().trace_id(), the traceId would be the one from parent_context

OpenTelemetry API Version (i.e version of opentelemetry crate)

0.28.0

OpenTelemetry SDK Version (i.e version of opentelemetry_sdk crate)

0.28.0

What Exporter(s) are you seeing the problem on?

OTLP

Relevant log output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage:todo Needs to be traiged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant