open-telemetry / open-telemetry/opentelemetry-python
Traces not being sent with auto instrumentation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
Describe your environment Describe any aspect of your environment relevant to the problem, including your Python version, platform, version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main.
#https://github.com/open-telemetry/opentelemetry-python/issues/3542
Steps to reproduce
run jaegertracing/all-in-one with appropriate port forwarding:
0.0.0.0:4317-4318->4317-4318/tcp, 0.0.0.0:5775->5775/udp, 0.0.0.0:5778->5778/tcp, 0.0.0.0:9411->9411/tcp, 0.0.0.0:14250->14250/tcp, 0.0.0.0:14268-14269->14268-14269/tcp, 0.0.0.0:16686->16686/tcp, 0.0.0.0:6831-6832->6831-6832/udp jaeger
create a simple fastAPI app that gets a span, does something to it, and ends it, and run the following command
opentelemetry-instrument
--traces_exporter otlp
--metrics_exporter otlp
--service_name some-service
--exporter_otlp_endpoint http://localhost:4317
...start command
adding
resource = Resource(attributes={SERVICE_NAME: PYTHON_SERVICE_NAME})
traceProvider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(
OTLPSpanExporter(
endpoint=f"http://localhost:4317",
insecure=True,
)
)
traceProvider.add_span_processor(processor)
trace.set_tracer_provider(traceProvider)
if app:
FastAPIInstrumentor.instrument_app(app, tracer_provider=traceProvider)
makes it so traces work properly, but warn: Overriding of current TracerProvider is not allowed [opentelemetry.trace] otelServiceName=llama-indexer otelSpanID=0 otelTraceID=0 otelTraceSampled=False
Attempting to instrument FastAPI app while already instrumented [opentelemetry.instrumentation.fastapi] otelServiceName=llama-indexer otelSpanID=0 otelTraceID=0 otelTraceSampled=False
I have another service, using Node.js, that is able to export metrics and traces with no issues
**What is the expected behavior?**
traces and metrics appear in jager correctly with no errors
**What is the actual behavior?**
no traces
**Additional context**
Add any other context about the problem here.
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 with the opentelemetry-instrument entry point and the FastAPIInstrumentor.instrument_app path, then reproduce the reported setup with Jaeger and the provided OTLP endpoint. Compare automatic instrumentation with the explicit tracer-provider configuration and verify whether traces and metrics appear without the reported warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- api, backend, observability
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100