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

TraceID is the same for all spans #3172

Open
ty-elastic opened this issue Jan 6, 2025 · 5 comments · May be fixed by #3174
Open

TraceID is the same for all spans #3172

ty-elastic opened this issue Jan 6, 2025 · 5 comments · May be fixed by #3174
Assignees
Labels
bug Something isn't working

Comments

@ty-elastic
Copy link

ty-elastic commented Jan 6, 2025

Describe your environment

OS: python:3.12.6-slim-bookworm
Python version: python:3.12.6
SDK version: 0.50b0/1.29.0
API version: 0.50b0/1.29.0

What happened?

Create a simple zero-code Python app invoked with opentelemetry-instrument. Whether you use auto-instrumentation (here, a flask endpoint) or add manual instrumentation (@tracer.start_as_current_span), the Trace IDs created for subsequent traces are all the same when using version 0.50b0/1.29.0. Keeping everything else the same, using 0.49b2/1.28.2, Trace IDs are randomly generated.

Steps to Reproduce

See https://github.com/ty-elastic/otel-python-bug and observe Collector debug output varying the version of the python OTel libraries used.

Basically, create a simple python app and use zero-code instrumentation. Either use an auto-instrumented library (like flask) or manually create spans. Using 0.50b0/1.29.0, Trace ID doesn't change between traces; using 0.49b2/1.28.2 it does (as expected).

Expected Result

Trace ID is randomly generated.

Actual Result

Trace ID is the same for every trace.

Additional context

No response

Would you like to implement a fix?

No

@ty-elastic ty-elastic added the bug Something isn't working label Jan 6, 2025
@xrmx
Copy link
Contributor

xrmx commented Jan 6, 2025

@ty-elastic could you please check if pip3 uninstall opentelemetry-instrumentation-click after the opentelemetry-bootstrap call helps?

@ty-elastic
Copy link
Author

ty-elastic commented Jan 6, 2025

yes, indeed, that fixes it. I now see random Trace IDs for each trace generated.

@ty-elastic
Copy link
Author

ty-elastic commented Jan 6, 2025

@xrmx , I'm casually looking at the source of that instrumentation. What is it that would cause Trace ID not to be regenerated? Presumably that instrumentation is somehow being invoked to create a new Trace when my app is run, with that singular Trace ID on the context as the active parent, and then everything else is inherently a child span? Is there something about thew way I'm invoking my app that is triggering the click instrumentation to get accidentally hooked?

@xrmx
Copy link
Contributor

xrmx commented Jan 7, 2025

@xrmx , I'm casually looking at the source of that instrumentation. What is it that would cause Trace ID not to be regenerated? Presumably that instrumentation is somehow being invoked to create a new Trace when my app is run, with that singular Trace ID on the context as the active parent, and then everything else is inherently a child span? Is there something about thew way I'm invoking my app that is triggering the click instrumentation to get accidentally hooked?

flask run under the hood is a click command, and one that lives forever so all the requests spans would be children of the very same root span. We should stop instrumenting flask run by default as it creates more harm than good 😅

@emdneto
Copy link
Member

emdneto commented Jan 7, 2025

Also related: #3171
flask spans are also marked as kind.Internal since there's already a current-span in context (the click command one)

@xrmx xrmx self-assigned this Jan 7, 2025
@xrmx xrmx transferred this issue from open-telemetry/opentelemetry-python Jan 7, 2025
@xrmx xrmx linked a pull request Jan 7, 2025 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants