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

Remove pkg_resource and replace for importlib.metadata #2180

Closed
Rodrigo-Novas opened this issue Feb 14, 2024 · 2 comments · Fixed by #2871
Closed

Remove pkg_resource and replace for importlib.metadata #2180

Rodrigo-Novas opened this issue Feb 14, 2024 · 2 comments · Fixed by #2871
Labels
bug Something isn't working

Comments

@Rodrigo-Novas
Copy link
Contributor

Rodrigo-Novas commented Feb 14, 2024

Describe your environment

Docker environment
Image so: ubuntu:20.04
Python version: 3.9

Otel dependencies:

opentelemetry-api = "^1.14.0"
opentelemetry-semantic-conventions = "0.41b0" # At the moment there are no releases without beta
opentelemetry-instrumentation-urllib3 = "0.41b0" # At the moment there are no releases without beta
opentelemetry-instrumentation-httpx = "0.41b0" # At the moment there are no releases without beta

Steps to reproduce

Instrument any app and run it, it will throws a warning deprecation message about pkg_resource.

I created a CM of spans with something like this:

from opentelemetry import trace
@contextlib.contextmanager
def create_span(tracer: trace.Tracer) -> Generator:
    "Start the span as current span."
    name = "name"
    _kind = "kind"
    with tracer.start_as_current_span(
        name,
        kind=_kind,
        record_exception=False,
    ) as current_span:
        yield current_span

What is the expected behavior?

Otel doesnt throws a deprecationWarning

What is the actual behavior?

The output is a deprecation warning:

DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

Additional context

Use of pkg_resources is deprecated

@Rodrigo-Novas Rodrigo-Novas added the bug Something isn't working label Feb 14, 2024
@Rodrigo-Novas
Copy link
Contributor Author

I created a fix about this on #2181

@theunkn0wn1
Copy link

FYI pkg_resources is deprecated AND REMOVED in modern python versions.
This package now depends on an undeclared dependency and is thus broken.

backend        |     from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
backend        |   File "/home/nonroot/.local/lib/python3.12/site-packages/opentelemetry/instrumentation/sqlalchemy/__init__.py", line 105, in <module>
backend        |     from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
backend        |   File "/home/nonroot/.local/lib/python3.12/site-packages/opentelemetry/instrumentation/instrumentor.py", line 27, in <module>
backend        |     from opentelemetry.instrumentation.dependencies import (
backend        |   File "/home/nonroot/.local/lib/python3.12/site-packages/opentelemetry/instrumentation/dependencies.py", line 4, in <module>
backend        |     from pkg_resources import (
backend        | ModuleNotFoundError: No module named 'pkg_resources'

@xrmx xrmx mentioned this issue Oct 17, 2024
11 tasks
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