You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using CloudTraceFormatPropagator for GCP, X-Cloud-Trace-Context header cannot be retrieved.
Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
# server.py
import uvicorn
from fastapi import FastAPI, Request
from opentelemetry import trace
from opentelemetry.propagators import set_global_textmap
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.tools import cloud_trace_propagator
set_global_textmap(cloud_trace_propagator.CloudTraceFormatPropagator())
app = FastAPI()
tracer = trace.get_tracer("test")
FastAPIInstrumentor.instrument_app(app)
@app.get("/trace")
async def test(r: Request):
with tracer.start_as_current_span("test") as span:
trace_id = span.get_span_context().trace_id
print(f"{trace_id:32x}") # should print trace ID from `X-Cloud-Trace-Context` header value
uvicorn.run(app)
# client.py
import requests
r = requests.Session()
r.headers.setdefault("X-Cloud-Trace-Context",
"f3ef5c2ede256aa77491057e600eca11/15104302039794794507;o=1")
r.get("http://localhost:8000/trace")
What is the expected behavior?
Printed value should be f3ef5c2ede256aa77491057e600eca11 based from the header sent
What is the actual behavior?
A newly generated value everything /trace is called
Additional context X-Cloud-Trace-Context header value is not retrieved properly in CloudTraceFormatPropagator
The text was updated successfully, but these errors were encountered:
Environment:
Python: python3.8
fastapi==0.63.0
opentelemetry-api==0.16b1
opentelemetry-sdk==0.16b1
opentelemetry-instrumentation-fastapi==0.16b1
opentelemetry-exporter-google-cloud==0.16b1
opentelemetry-tools-google-cloud==0.16b1
When using
CloudTraceFormatPropagator
for GCP,X-Cloud-Trace-Context
header cannot be retrieved.Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
What is the expected behavior?
Printed value should be
f3ef5c2ede256aa77491057e600eca11
based from the header sentWhat is the actual behavior?
A newly generated value everything
/trace
is calledAdditional context
X-Cloud-Trace-Context
header value is not retrieved properly inCloudTraceFormatPropagator
The text was updated successfully, but these errors were encountered: