opentelemetry-python-contrib
opentelemetry-python-contrib copied to clipboard
auto_instrumentation.initialize() leads to a flurry of ModuleNotFoundError errors when traceloop-sdk is present
Describe your environment
OS: Macos Python version: 3.11.8 Package versions: opentelemetry-distro==0.52b0 opentelemetry-exporter-otlp==1.31.0
What happened?
Trying to make traceloop-sdk and opentelemetry-python programmatic auto-instrumentation play together but it leads to unexpected errors.
We see a flurry of these stacktraces which look very noisy (trimmed after the first stacktrace). These libraries are not part of bootstrap_gen, but rather openllmetry. All of the stacktraces point to instrumentation/distro.py looking these modules. That doesn't feel like it's expected.
Importing of qdrant_client failed, skipping it
Traceback (most recent call last):
File "/Users/abhishek.rao/code/work/openllmetry-bug/.venv/lib/python3.11/site-packages/opentelemetry/instrumentation/auto_instrumentation/_load.py", line 114, in _load_instrumentors
distro.load_instrumentor(entry_point, skip_dep_check=True)
File "/Users/abhishek.rao/code/work/openllmetry-bug/.venv/lib/python3.11/site-packages/opentelemetry/instrumentation/distro.py", line 61, in load_instrumentor
instrumentor: BaseInstrumentor = entry_point.load()
^^^^^^^^^^^^^^^^^^
File "/Users/abhishek.rao/code/work/openllmetry-bug/.venv/lib/python3.11/site-packages/importlib_metadata/__init__.py", line 189, in load
module = import_module(match.group('module'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/abhishek.rao/.pyenv/versions/3.11.1/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/Users/abhishek.rao/code/work/openllmetry-bug/.venv/lib/python3.11/site-packages/opentelemetry/instrumentation/qdrant/__init__.py", line 8, in <module>
import qdrant_client
ModuleNotFoundError: No module named 'qdrant_client'
...
ModuleNotFoundError: No module named 'qdrant_client'
...
ModuleNotFoundError: No module named 'mistralai'
...
ModuleNotFoundError: No module named 'haystack'
...
ModuleNotFoundError: No module named 'pinecone'
...
ModuleNotFoundError: No module named 'chromadb'
...
ModuleNotFoundError: No module named 'llama_index'
...
ModuleNotFoundError: No module named 'crewai'
...
ModuleNotFoundError: No module named 'lancedb'
...
ModuleNotFoundError: No module named 'pymilvus'
...
ModuleNotFoundError: No module named 'aleph_alpha_client'
...
ModuleNotFoundError: No module named 'google.generativeai'
...
ModuleNotFoundError: No module named 'weaviate'
...
ModuleNotFoundError: No module named 'marqo'
...
ModuleNotFoundError: No module named 'cohere'
...
ModuleNotFoundError: No module named 'replicate'
...
ModuleNotFoundError: No module named 'groq'
...
ModuleNotFoundError: No module named 'ibm_watson_machine_learning'
...
ModuleNotFoundError: No module named 'together'
...
ModuleNotFoundError: No module named 'vertexai'
Steps to Reproduce
Run a simple python app with poetry. Sample requirements.txt:
opentelemetry-distro==0.52b0
opentelemetry-exporter-otlp==1.31.0
langgraph==0.1.16
pydantic==2.9.0
langchain==0.2.11
ruamel-yaml==0.18.6
gunicorn==22.0.0
humanize==4.10.0
tenacity==8.4.1
kubernetes==31.0.0
pandas==2.2.3
async-lru==2.0.4
asyncstdlib==3.13.0
tqdm==4.67.1
pydantic-extra-types==2.9.0
uvicorn==0.34.0
fastapi==0.115.10
traceloop-sdk
Where app.py contains:
from opentelemetry.instrumentation import auto_instrumentation
auto_instrumentation.initialize()
Expected Result
Zero-code instrumentation should only honour its own scope of modules to auto-instrument.
Actual Result
Zero-code instrumentation conflicts with traceloop-sdk auto-instrumentation and tries to take over, even when simply installing traceloop-sdk, without even calling it.
Additional context
No response
Would you like to implement a fix?
None