Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several auto-instrumentation failures with TypeError (urllib, flask, sqlite3, logging) on dev version #3167

Closed
tammy-baylis-swi opened this issue Jan 3, 2025 · 2 comments · Fixed by #3168
Assignees
Labels
bug Something isn't working

Comments

@tammy-baylis-swi
Copy link
Contributor

tammy-baylis-swi commented Jan 3, 2025

Describe your environment

OS: Ubuntu
Python version: 3.12.8
SDK version: 1.30.0dev
API version: 0.51b0dev

What happened?

opentelemetry-bootstrap and opentelemetry-instrument using Otel's opentelemetry-distro at main branch (1.30.0dev/0.51b0dev) fail with an error stack at loading of the urllib/Flask/sqlite3/logging instrumentor at app startup. urllib, sqlite3, and logging are some of the default_instrumentations:

Instrumenting of urllib failed
Traceback (most recent call last):
  File "/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 104, in _load_instrumentors
    conflict = get_dist_dependency_conflicts(entry_point_dist)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py", line 50, in get_dist_dependency_conflicts
    for dep in dist.requires:
               ^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
Failed to auto initialize opentelemetry
Traceback (most recent call last):
  File "/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py", line 39, in initialize
    _load_instrumentors(distro)
  File "/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 129, in _load_instrumentors
    raise exc
  File "/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 104, in _load_instrumentors
    conflict = get_dist_dependency_conflicts(entry_point_dist)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opentelemetry-python-contrib/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py", line 50, in get_dist_dependency_conflicts
    for dep in dist.requires:
               ^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

This also happens with the instrumentors for Flask, sqlite3, and logging. The TypeError eventually stops if I set OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=flask,logging,sqlite3,urllib

This doesn't happen with latest release 1.29.0/0.50b0.

EDIT: This is a separate issue. something else odd happens and I'm not sure if related. Spans from opentelemetry-instrumentation-flask end up being kind Internal instead of Server. Either way, error stacks not good.

Steps to Reproduce

I'm using main branches of the SDK and API (1.30.0dev/0.51b0dev) to auto-instrument a basic Flask app:

pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
opentelemetry-instrument flask run

with app.py as:

from flask import Flask

app = Flask(__name__)

@app.route("/abc/")
def request_abc():
    return "Done"

The TypeError stops if I set OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=flask,logging,sqlite3,urllib but I want to instrument those frameworks.

Expected Result

No error traces

Actual Result

Error trace as above

Additional context

No response

Would you like to implement a fix?

None

@tammy-baylis-swi tammy-baylis-swi added the bug Something isn't working label Jan 3, 2025
@tammy-baylis-swi tammy-baylis-swi changed the title Several instrumentation failures with TypeError (urllib, flask, sqlite3, logging) on dev version Several auto-instrumentation failures with TypeError (urllib, flask, sqlite3, logging) on dev version Jan 3, 2025
@tammy-baylis-swi tammy-baylis-swi self-assigned this Jan 4, 2025
@xrmx
Copy link
Contributor

xrmx commented Jan 8, 2025

Strange, I have opentelemetry-instrument working without issues with Python 3.10 on yesterday main with the flask instrumentor. @tammy-baylis-swi What version of importlib-metadata do you have?

@xrmx xrmx closed this as completed in #3168 Jan 8, 2025
@tammy-baylis-swi
Copy link
Contributor Author

This was with importlib-metadata-8.5.0 on Python 3.12, from the API bounds

Collecting importlib-metadata<=8.5.0,>=6.0 (from opentelemetry-api==1.29.0.dev0)
  Downloading importlib_metadata-8.5.0-py3-none-any.whl.metadata (4.8 kB)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants