Remove pkg resources (#2871)

This commit is contained in:
Riccardo Magliocchetti
2024-10-19 15:49:08 +02:00
committed by GitHub
parent d7d7e96ce5
commit e4ece57a81
101 changed files with 247 additions and 262 deletions

View File

@ -15,10 +15,9 @@
from unittest import TestCase
from pkg_resources import EntryPoint
from opentelemetry.instrumentation.distro import BaseDistro
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.util._importlib_metadata import EntryPoint
class MockInstrumetor(BaseInstrumentor):
@ -33,11 +32,13 @@ class MockInstrumetor(BaseInstrumentor):
class MockEntryPoint(EntryPoint):
def __init__(self, obj): # pylint: disable=super-init-not-called
self._obj = obj
def __init__(
self, name, value, group
): # pylint: disable=super-init-not-called
pass
def load(self, *args, **kwargs): # pylint: disable=signature-differs
return self._obj
return MockInstrumetor
class MockDistro(BaseDistro):
@ -51,7 +52,11 @@ class TestDistro(TestCase):
distro = MockDistro()
instrumentor = MockInstrumetor()
entry_point = MockEntryPoint(MockInstrumetor)
entry_point = MockEntryPoint(
"MockInstrumetor",
value="opentelemetry",
group="opentelemetry_distro",
)
self.assertFalse(instrumentor._is_instrumented_by_opentelemetry)
distro.load_instrumentor(entry_point)