open-telemetry / open-telemetry/opentelemetry-python-contrib
Invalid Span Extracted when using XrayPropagator
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
Python 3.11
FastAPI 0.103.0
opentelemetry-instrumentation-fastapi==0.41b0
opentelemetry-propagator-aws-xray==1.0.1
opentelemetry-sdk==1.20.0
Steps to reproduce
Minimal example.
propagate.set_global_textmap(AwsXRayPropagator())
resource = Resource.create(attributes={"service.name": "test-service"})
tracer = TracerProvider(resource=resource)
jaeger_exporter = JaegerExporter(
agent_host_name="localhost",
agent_port=6831,
)
processor = BatchSpanProcessor(jaeger_exporter)
tracer.add_span_processor(processor)
samp = ParentBased(ALWAYS_ON)
trace.set_tracer_provider(
TracerProvider(
resource=resource,
active_span_processor=processor,
id_generator=AwsXRayIdGenerator(),
sampler=samp
)
)
tracer = trace.get_tracer(__name__)
app = FastAPI(title="test api", version="draft")
FastAPIInstrumentor().instrument_app(app, tracer_provider=trace.get_tracer_provider())
@app.get("/system/ping")
async def ping() -> dict:
return {"message": "pong"}
if __name__ == '__main__':
uvicorn.run(app, host='0.0.0.0', port=8081,
log_config='logging_conf.yml',
workers=1)
What is the expected behavior?
Passing in the below header as an example.
X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793
I would expect Xray to join up traces across services as a linked trace or part of the same trace
What is the actual behavior?
Traces coming through to Xray unlinked and the following error.
Invalid Span Extracted. Inserting INVALID span into provided context.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the supplied FastAPI example and X-Amzn-Trace-Id header, then trace XrayPropagator's extraction path where the invalid span is reported. Done means incoming X-Ray context is accepted so spans are linked across services and the invalid-span error no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, fastapi, python
- Domain
- api, backend, observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100