Description
Describe your environment
OS: Alpine (container) and MacOS arm64 (local)
Python version: Python 3.11.9
Package version: 0.50b0
What happened?
When using the autoinstrumentation with 0.50b0 all of the incoming requests to my FastAPI application get the same trace id when incoming requests do not have trace headers.
Steps to Reproduce
requirements.txt
fastapi
uvicorn[standard]
opentelemetry-distro==0.50b0
opentelemetry-exporter-otlp==1.29.0
main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def get_root():
return 'Hello World'
run app
pip install -r requirements.txt
opentelemetry-bootstrap -a install
OTEL_TRACES_EXPORTER=console OTEL_METRICS_EXPORTER=none opentelemetry-instrument uvicorn main:app
Expected Result
curl localhost:8000 && curl localhost:8000
I expect to see two different trace_id's in the spans exported to the console. I get that result when using 0.49b0 and 0.48b0 for the opentelemetry-distro.
Actual Result
I see the same value for trace_id in the spans.
Additional context
When stopping the app I see another span for "uvicorn" with a duration of the start/end times aligning with when I started and stopped the app and a span_id equal to the parent_id of the spans for "GET /".
{
"name": "uvicorn",
"context": {
"trace_id": "0x4e6f724cba54c84879bb2421d0957770",
"span_id": "0xa1b218a42b2cc4cf",
"trace_state": "[]"
},
"kind": "SpanKind.INTERNAL",
"parent_id": null,
"start_time": "2025-01-31T19:31:38.898348Z",
"end_time": "2025-01-31T19:32:18.319662Z",
"status": {
"status_code": "UNSET"
},
"attributes": {
"process.command_args": [
"/Users/dev/python_otel_trace_propagation/venv-broken/bin/uvicorn",
"main:app"
],
"process.executable.name": "/Users/dev/python_otel_trace_propagation/venv-broken/bin/uvicorn",
"process.exit.code": 0,
"process.pid": 45529
},
"events": [],
"links": [],
"resource": {
"attributes": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "1.29.0",
"telemetry.auto.version": "0.50b0",
"service.name": "unknown_service"
},
"schema_url": ""
}
}
Would you like to implement a fix?
None
Activity