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

Confluent kafka instrumentation doesn't define instrumentation and semconv dependencies

Open Lameorc opened this issue 2 years ago • 0 comments
trafficstars

Describe your environment Python 3.10.4 (also reproduced in other versions) Ubuntu 22.04.2 LTS x86_64 pip freeze output:

confluent-kafka==2.2.0
Deprecated==1.2.14
exceptiongroup==1.1.2
importlib-metadata==6.8.0
iniconfig==2.0.0
opentelemetry-api==1.19.0
opentelemetry-instrumentation-confluent-kafka==0.40b0
packaging==23.1
pluggy==1.2.0
pytest==7.4.0
tomli==2.0.1
wrapt==1.15.0
zipp==3.16.2

Steps to reproduce Create a new python "project" with following files (I've attached the directory just in case):

  • main.py

    from opentelemetry.instrumentation.confluent_kafka import ConfluentKafkaInstrumentor
    
    
    def main() -> None:
         ConfluentKafkaInstrumentor().instrument()
    
  • test_main.py

    from main import main
    
    def test_main():
        main()
    
  • requirements.txt

    pytest
    confluent-kafka
    opentelemetry-api
    opentelemetry-instrumentation-confluent-kafka
    

install the requirements pip install -r requirements.txt run the test pytest ./

What is the expected behavior? The instrumentation succeeds and imports work.

What is the actual behavior?

========================================== test session starts ===========================================
platform linux -- Python 3.10.4, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/vpodhajsky/Notes/otel-broken
collected 0 items / 1 error

================================================= ERRORS =================================================
_____________________________________ ERROR collecting test_main.py ______________________________________
ImportError while importing test module '/home/vpodhajsky/Notes/otel-broken/test_main.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.pyenv/versions/3.10.4/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_main.py:1: in <module>
    from main import main
main.py:1: in <module>
    from opentelemetry.instrumentation.confluent_kafka import ConfluentKafkaInstrumentor
venv/lib/python3.10/site-packages/opentelemetry/instrumentation/confluent_kafka/__init__.py:107: in <module>
    from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
E   ModuleNotFoundError: No module named 'opentelemetry.instrumentation.instrumentor'
======================================== short test summary info =========================================
ERROR test_main.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================ 1 error in 0.10s ============================================

Additional context We're moving from kafka-python instrumentation to confluent-kafka and thus changing the instrumentation used. kafka-python seems to explicitely define semconv and instrumentation, while the confluent-kafka doesn't as far as I can tell. So I think the fix here would be to just add these dependencies explicitly as installing them manually fixes the issue.

Lameorc avatar Jul 19 '23 13:07 Lameorc