Skip to content

Remove pkg_resource and replace for importlib.metadata #2180

@Rodrigo-Novas

Description

@Rodrigo-Novas

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions