opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Traces not being sent with auto instrumentation

Open Sammyjroberts opened this issue 1 year ago • 1 comments

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.

Sammyjroberts avatar Feb 28 '24 00:02 Sammyjroberts

After more testing, if i do not add the programatic instrumentation, distributed traces show in the python service but not my api service (node.js)

However if i remove the programatic instrumentation, and only include the auto instrumentation, the traces appear in the python service, but not in the api service

Sammyjroberts avatar Feb 28 '24 19:02 Sammyjroberts

After more testing, if i do not add the programatic instrumentation, distributed traces show in the python service but not my api service (node.js)

However if i remove the programatic instrumentation, and only include the auto instrumentation, the traces appear in the python service, but not in the api service

wow. what.

naisanzaa avatar Apr 03 '24 08:04 naisanzaa

Hi @Sammyjroberts, since you've set up instrumentation manually, have you tried removing the opentelemetry-instrument command? You'll want to either do manual instrumentation as you've demonstrated above, or auto instrumentation via opentelemetry-instrument, but not both.

pmcollins avatar Apr 08 '24 20:04 pmcollins