open-telemetry / opentelemetry-python

OpenTelemetry Python API and SDK
https://opentelemetry.io
Apache License 2.0
1.79k stars 624 forks source link

OTEL_PROPAGATORS does not support "none" value #4143

Open M-Sayed opened 2 months ago

M-Sayed commented 2 months ago

Describe your environment

OS: Linux/amd64 Python version: Python 3.12 SDK version: I installed following libs using pip, so I assume the latest version (opentelemetry-exporter-otlp opentelemetry-instrumentation-requests opentelemetry-instrumentation-flask) API version: I installed following libs using pip, so I assume the latest version (opentelemetry-exporter-otlp opentelemetry-instrumentation-requests opentelemetry-instrumentation-flask)

What happened?

It seems that I can't disable context propagation in Python by setting the OTEL_PROPAGATORS ENV variable to none as mentioned here.

When trying to do so, I get the following error:

{
  "message": "Uncaught exception",
  "traceback": "Traceback (most recent call last):
    File \"/usr/local/lib/python3.12/site-packages/opentelemetry/propagate/__init__.py\", line 139, in <module>
      next(  # type: ignore
  StopIteration

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File \"/cert-issuer/wsgi.py\", line 1, in <module>
      from app import app
    File \"/cert-issuer/app.py\", line 24, in <module>
      setup_instrument(app)
    File \"/cert-issuer/accredible/setup_instrument.py\", line 24, in setup_instrument
      from opentelemetry.instrumentation.flask import FlaskInstrumentor
    File \"/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/flask/__init__.py\", line 251, in <module>
      import opentelemetry.instrumentation.wsgi as otel_wsgi
    File \"/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/wsgi/__init__.py\", line 216, in <module>
      from opentelemetry.instrumentation._semconv import (
    File \"/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/_semconv.py\", line 19, in <module>
      from opentelemetry.instrumentation.utils import http_status_to_status_code
    File \"/usr/local/lib/python3.12/site-packages/opentelemetry/instrumentation/utils.py\", line 32, in <module>
      from opentelemetry.propagate import extract
    File \"/usr/local/lib/python3.12/site-packages/opentelemetry/propagate/__init__.py\", line 149, in <module>
      raise ValueError(
  ValueError: Propagator none not found. It is either misspelled or not installed."
}

It seems that error happens at this line and it's because we are missing the none propagator definition here in opentelemetry-api/pyproject.toml. (I am not a python expert, so my assumption can be wrong)

Steps to Reproduce

Expected Result

No errors are expected, and automatic propagation is disabled.

Actual Result

Error that the none propagator is not defined.

Additional context

I am not sure if setting the OTEL_PROPAGATORS="" will be valid, but according to the documentation, none should be a valid value.

Would you like to implement a fix?

None

Rajamanosankari commented 1 month ago

I would like to work on this issue

Ali-Alnosairi commented 1 month ago

Hi @xrmx, Can I work on it ?

lzchen commented 1 month ago

@Ali-Alnosairi

I believe @Rajamanosankari has already been assigned to this issue. Feel free to reach out to them if you'd like to collaborate or take over.

Annosha commented 4 weeks ago

@lzchen I am an Outreachy contributor for project. This is my first contribution to otel-python repo. If @Rajamanosankari isn't working can I take on this issue? Thanks

lzchen commented 2 weeks ago

@Annosha

Seeing as @Rajamanosankari has not responded in the thread I will reassign.