From 804d175be8c8bb14b6881464c5f1c0713bde293f Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Wed, 14 Feb 2024 16:31:44 -0300 Subject: [PATCH 01/37] feat: replace pkg_resource for importlib --- .../instrumentation/dependencies.py | 21 +++---------------- .../tests/test_dependencies.py | 8 +++---- .../tests/test_distro.py | 2 +- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 2da0a3d18b..9792c5a106 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -1,13 +1,7 @@ from logging import getLogger from typing import Collection, Optional -from pkg_resources import ( - Distribution, - DistributionNotFound, - RequirementParseError, - VersionConflict, - get_distribution, -) +from importlib.metadata import distribution, PackageNotFoundError, Distribution logger = getLogger(__name__) @@ -47,16 +41,7 @@ def get_dependency_conflicts( ) -> Optional[DependencyConflict]: for dep in deps: try: - get_distribution(dep) - except VersionConflict as exc: - return DependencyConflict(dep, exc.dist) - except DistributionNotFound: - return DependencyConflict(dep) - except RequirementParseError as exc: - logger.warning( - 'error parsing dependency, reporting as a conflict: "%s" - %s', - dep, - exc, - ) + distribution(dep) + except PackageNotFoundError: return DependencyConflict(dep) return None diff --git a/opentelemetry-instrumentation/tests/test_dependencies.py b/opentelemetry-instrumentation/tests/test_dependencies.py index 04bcf476ea..7f10d29a32 100644 --- a/opentelemetry-instrumentation/tests/test_dependencies.py +++ b/opentelemetry-instrumentation/tests/test_dependencies.py @@ -14,7 +14,7 @@ # pylint: disable=protected-access -import pkg_resources +from importlib.metadata import Distribution, requires import pytest from opentelemetry.instrumentation.dependencies import ( @@ -53,14 +53,12 @@ def test_get_dependency_conflicts_mismatched_version(self): def test_get_dist_dependency_conflicts(self): def mock_requires(extras=()): if "instruments" in extras: - return [ - pkg_resources.Requirement( + return requires( 'test-pkg ~= 1.0; extra == "instruments"' ) - ] return [] - dist = pkg_resources.Distribution( + dist = Distribution( project_name="test-instrumentation", version="1.0" ) dist.requires = mock_requires diff --git a/opentelemetry-instrumentation/tests/test_distro.py b/opentelemetry-instrumentation/tests/test_distro.py index 399b3f8a65..611b30048b 100644 --- a/opentelemetry-instrumentation/tests/test_distro.py +++ b/opentelemetry-instrumentation/tests/test_distro.py @@ -15,7 +15,7 @@ from unittest import TestCase -from pkg_resources import EntryPoint +from importlib.metadata import EntryPoint from opentelemetry.instrumentation.distro import BaseDistro from opentelemetry.instrumentation.instrumentor import BaseInstrumentor From e00d69908cbafcdbaaa4f6a256a54b6bba860092 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Wed, 14 Feb 2024 17:42:10 -0300 Subject: [PATCH 02/37] chore: add entry on changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b6c22af8..348a606204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,8 +29,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- `opentelemetry-instrumentation-kafka-python` Instrument temporary fork, kafka-python-ng - inside kafka-python's instrumentation +- Deprecation of pkg_resource in favor of importlib.metadata + ([#2180](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2180)) +- `opentelemetry-instrumentation-kafka-python` Instrument temporary fork, kafka-python-ng inside kafka-python's instrumentation ([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537)) - `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-fastapi` Add ability to disable internal HTTP send and receive spans ([#2802](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2802)) From c6effca0d75f59674c7878e27b4a0e42f5a3aa63 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Wed, 14 Feb 2024 18:35:27 -0300 Subject: [PATCH 03/37] feat: update to 132 --- .../auto_instrumentation/__init__.py | 6 +++--- .../instrumentation/auto_instrumentation/_load.py | 12 ++++++------ .../opentelemetry/instrumentation/bootstrap.py | 15 ++++----------- .../src/opentelemetry/instrumentation/distro.py | 2 +- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index a09334432d..24c3b19ef1 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -19,7 +19,7 @@ from re import sub from shutil import which -from pkg_resources import iter_entry_points +from importlib.metadata import entry_points from opentelemetry.instrumentation.version import __version__ @@ -48,8 +48,8 @@ def run() -> None: argument_otel_environment_variable = {} - for entry_point in iter_entry_points( - "opentelemetry_environment_variables" + for entry_point in entry_points().get( + "opentelemetry_environment_variables", [] ): environment_variable_module = entry_point.load() diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 27b57da3ef..25ddbfd4a8 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -15,7 +15,7 @@ from logging import getLogger from os import environ -from pkg_resources import iter_entry_points +from importlib.metadata import entry_points from opentelemetry.instrumentation.dependencies import ( get_dist_dependency_conflicts, @@ -33,7 +33,7 @@ def _load_distro() -> BaseDistro: distro_name = environ.get(OTEL_PYTHON_DISTRO, None) - for entry_point in iter_entry_points("opentelemetry_distro"): + for entry_point in entry_points().get("opentelemetry_distro", []): try: # If no distro is specified, use first to come up. if distro_name is None or distro_name == entry_point.name: @@ -63,10 +63,10 @@ def _load_instrumentors(distro): # to handle users entering "requests , flask" or "requests, flask" with spaces package_to_exclude = [x.strip() for x in package_to_exclude] - for entry_point in iter_entry_points("opentelemetry_pre_instrument"): + for entry_point in entry_points().get("opentelemetry_pre_instrument", []): entry_point.load()() - for entry_point in iter_entry_points("opentelemetry_instrumentor"): + for entry_point in entry_points().get("opentelemetry_instrumentor", []): if entry_point.name in package_to_exclude: _logger.debug( "Instrumentation skipped for library %s", entry_point.name @@ -90,14 +90,14 @@ def _load_instrumentors(distro): _logger.exception("Instrumenting of %s failed", entry_point.name) raise exc - for entry_point in iter_entry_points("opentelemetry_post_instrument"): + for entry_point in entry_points().get("opentelemetry_post_instrument", []): entry_point.load()() def _load_configurators(): configurator_name = environ.get(OTEL_PYTHON_CONFIGURATOR, None) configured = None - for entry_point in iter_entry_points("opentelemetry_configurator"): + for entry_point in entry_points().get("opentelemetry_configurator", []): if configured is not None: _logger.warning( "Configuration of %s not loaded, %s already loaded", diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index 1cc28abca4..22d93b0419 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -23,7 +23,7 @@ check_call, ) -import pkg_resources +from importlib.metadata import distribution, PackageNotFoundError from opentelemetry.instrumentation.bootstrap_gen import ( default_instrumentations, @@ -93,17 +93,10 @@ def _pip_check(): def _is_installed(req): if req in sys.modules: return True - + try: - pkg_resources.get_distribution(req) - except pkg_resources.DistributionNotFound: - return False - except pkg_resources.VersionConflict as exc: - logger.warning( - "instrumentation for package %s is available but version %s is installed. Skipping.", - exc.req, - exc.dist.as_requirement(), # pylint: disable=no-member - ) + distribution(req) + except PackageNotFoundError: return False return True diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py index 93646bbb2f..274886f42f 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py @@ -20,7 +20,7 @@ from abc import ABC, abstractmethod from logging import getLogger -from pkg_resources import EntryPoint +from importlib.metadata import EntryPoint from opentelemetry.instrumentation.instrumentor import BaseInstrumentor From 4bbd2d5362fe66163f5033eec2f04a227a0bdd8a Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Thu, 15 Feb 2024 21:06:55 -0300 Subject: [PATCH 04/37] feat: add dist logic and version conflict --- opentelemetry-instrumentation/pyproject.toml | 1 - .../auto_instrumentation/_load.py | 29 +++++++- .../instrumentation/bootstrap.py | 17 +++-- .../instrumentation/dependencies.py | 14 ++-- .../tests/auto_instrumentation/test_load.py | 72 ++++++++++++++++--- 5 files changed, 112 insertions(+), 21 deletions(-) diff --git a/opentelemetry-instrumentation/pyproject.toml b/opentelemetry-instrumentation/pyproject.toml index 866b9b5008..210e814bb6 100644 --- a/opentelemetry-instrumentation/pyproject.toml +++ b/opentelemetry-instrumentation/pyproject.toml @@ -27,7 +27,6 @@ classifiers = [ dependencies = [ "opentelemetry-api ~= 1.4", "opentelemetry-semantic-conventions >= 0.48b0", - "setuptools >= 16.0", "wrapt >= 1.0.0, < 2.0.0", ] diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 25ddbfd4a8..d5ab20faf7 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -15,7 +15,7 @@ from logging import getLogger from os import environ -from importlib.metadata import entry_points +from importlib.metadata import entry_points, EntryPoint, distributions from opentelemetry.instrumentation.dependencies import ( get_dist_dependency_conflicts, @@ -31,6 +31,29 @@ _logger = getLogger(__name__) +class _EntryPointDistFinder: + def __int__(self): + self._mapping = None + + def dist_for(self, entry_point: EntryPoint): + dist = getattr(entry_point, "dist", None) + if dist: + return dist + + if self._mapping is None: + self._mapping = { + self._key_for(ep): dist + for ep in dist.entry_points + for dist in distributions() + } + + return self._mapping.get(self._key_for(entry_point)) + + @staticmethod + def _key_for(entry_point: EntryPoint): + return f"{entry_point.group}:{entry_point.name}:{entry_point.value}" + + def _load_distro() -> BaseDistro: distro_name = environ.get(OTEL_PYTHON_DISTRO, None) for entry_point in entry_points().get("opentelemetry_distro", []): @@ -58,6 +81,7 @@ def _load_distro() -> BaseDistro: def _load_instrumentors(distro): package_to_exclude = environ.get(OTEL_PYTHON_DISABLED_INSTRUMENTATIONS, []) + entry_point_finder = _EntryPointDistFinder() if isinstance(package_to_exclude, str): package_to_exclude = package_to_exclude.split(",") # to handle users entering "requests , flask" or "requests, flask" with spaces @@ -74,7 +98,8 @@ def _load_instrumentors(distro): continue try: - conflict = get_dist_dependency_conflicts(entry_point.dist) + entry_point_dist = entry_point_finder.dist_for(entry_point) + conflict = get_dist_dependency_conflicts(entry_point_dist) if conflict: _logger.debug( "Skipping instrumentation %s: %s", diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index 22d93b0419..81316f9ecb 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -23,7 +23,8 @@ check_call, ) -from importlib.metadata import distribution, PackageNotFoundError +from packaging.requirements import Requirement +from importlib.metadata import PackageNotFoundError, version from opentelemetry.instrumentation.bootstrap_gen import ( default_instrumentations, @@ -91,13 +92,21 @@ def _pip_check(): def _is_installed(req): - if req in sys.modules: - return True + req = Requirement(req) try: - distribution(req) + dist_version = version(req.name) except PackageNotFoundError: return False + + if not req.specifier.filter(dist_version): + logger.warning( + "instrumentation for package %s is available" + " but version %s is installed. Skipping.", + req, + dist_version + ) + return False return True diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 9792c5a106..1ea4e9a3a4 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -1,7 +1,8 @@ from logging import getLogger from typing import Collection, Optional -from importlib.metadata import distribution, PackageNotFoundError, Distribution +from packaging.requirements import Requirement +from importlib.metadata import PackageNotFoundError, Distribution, requires, version logger = getLogger(__name__) @@ -21,9 +22,9 @@ def __str__(self): def get_dist_dependency_conflicts( dist: Distribution, ) -> Optional[DependencyConflict]: - main_deps = dist.requires() + main_deps = dist.requires instrumentation_deps = [] - for dep in dist.requires(("instruments",)): + for dep in requires(("instruments",)): if dep not in main_deps: # we set marker to none so string representation of the dependency looks like # requests ~= 1.0 @@ -40,8 +41,11 @@ def get_dependency_conflicts( deps: Collection[str], ) -> Optional[DependencyConflict]: for dep in deps: + req = Requirement(dep) try: - distribution(dep) + dist_version = version(req.name) except PackageNotFoundError: - return DependencyConflict(dep) + return DependencyConflict(req.name) + if not req.specifier.filter(dist_version): + return DependencyConflict(req.name) return None diff --git a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py index 5fc59b542d..9b0941bafa 100644 --- a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py +++ b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py @@ -30,7 +30,13 @@ class TestLoad(TestCase): "os.environ", {OTEL_PYTHON_CONFIGURATOR: "custom_configurator2"} ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_configurators( self, iter_mock @@ -61,7 +67,13 @@ def test_load_configurators( "os.environ", {OTEL_PYTHON_CONFIGURATOR: "custom_configurator2"} ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_configurators_no_ep( self, iter_mock @@ -74,7 +86,13 @@ def test_load_configurators_no_ep( "os.environ", {OTEL_PYTHON_CONFIGURATOR: "custom_configurator2"} ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_configurators_error(self, iter_mock): # Add multiple entry points but only specify the 2nd in the environment variable. @@ -101,7 +119,13 @@ def test_load_configurators_error(self, iter_mock): "opentelemetry.instrumentation.auto_instrumentation._load.isinstance" ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_distro(self, iter_mock, isinstance_mock): # Add multiple entry points but only specify the 2nd in the environment variable. @@ -134,7 +158,13 @@ def test_load_distro(self, iter_mock, isinstance_mock): "opentelemetry.instrumentation.auto_instrumentation._load.DefaultDistro" ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_distro_not_distro( self, iter_mock, default_distro_mock, isinstance_mock @@ -166,7 +196,13 @@ def test_load_distro_not_distro( "opentelemetry.instrumentation.auto_instrumentation._load.DefaultDistro" ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_distro_no_ep(self, iter_mock, default_distro_mock): iter_mock.return_value = () @@ -181,7 +217,13 @@ def test_load_distro_no_ep(self, iter_mock, default_distro_mock): "opentelemetry.instrumentation.auto_instrumentation._load.isinstance" ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_distro_error(self, iter_mock, isinstance_mock): ep_mock1 = Mock() @@ -211,7 +253,13 @@ def test_load_distro_error(self, iter_mock, isinstance_mock): "opentelemetry.instrumentation.auto_instrumentation._load.get_dist_dependency_conflicts" ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_instrumentors(self, iter_mock, dep_mock): # Mock opentelemetry_pre_instrument entry points @@ -285,7 +333,13 @@ def test_load_instrumentors(self, iter_mock, dep_mock): "opentelemetry.instrumentation.auto_instrumentation._load.get_dist_dependency_conflicts" ) @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.iter_entry_points" + "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.distributions" + ) + @patch( + "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" ) def test_load_instrumentors_dep_conflict( self, iter_mock, dep_mock From 199e6876bacc0c09133e22e76d758b6313b8bb07 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Tue, 20 Feb 2024 19:30:47 -0300 Subject: [PATCH 05/37] feat: add requirements solution --- opentelemetry-instrumentation/pyproject.toml | 2 + .../auto_instrumentation/__init__.py | 4 +- .../auto_instrumentation/_load.py | 10 ++-- .../instrumentation/dependencies.py | 47 ++++++++++++------- .../tests/test_dependencies.py | 19 ++++++-- 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/opentelemetry-instrumentation/pyproject.toml b/opentelemetry-instrumentation/pyproject.toml index 210e814bb6..a9435038bb 100644 --- a/opentelemetry-instrumentation/pyproject.toml +++ b/opentelemetry-instrumentation/pyproject.toml @@ -28,6 +28,8 @@ dependencies = [ "opentelemetry-api ~= 1.4", "opentelemetry-semantic-conventions >= 0.48b0", "wrapt >= 1.0.0, < 2.0.0", + "importlib-metadata >= 6.0, < 7.0", + "packaging >= 18.0", ] [project.scripts] diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index 24c3b19ef1..adea9e1f0c 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -48,9 +48,7 @@ def run() -> None: argument_otel_environment_variable = {} - for entry_point in entry_points().get( - "opentelemetry_environment_variables", [] - ): + for entry_point in entry_points(group="opentelemetry_environment_variables"): environment_variable_module = entry_point.load() for attribute in dir(environment_variable_module): diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index d5ab20faf7..0f00fbbcb2 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -56,7 +56,7 @@ def _key_for(entry_point: EntryPoint): def _load_distro() -> BaseDistro: distro_name = environ.get(OTEL_PYTHON_DISTRO, None) - for entry_point in entry_points().get("opentelemetry_distro", []): + for entry_point in entry_points(group="opentelemetry_distro"): try: # If no distro is specified, use first to come up. if distro_name is None or distro_name == entry_point.name: @@ -87,10 +87,10 @@ def _load_instrumentors(distro): # to handle users entering "requests , flask" or "requests, flask" with spaces package_to_exclude = [x.strip() for x in package_to_exclude] - for entry_point in entry_points().get("opentelemetry_pre_instrument", []): + for entry_point in entry_points(group="opentelemetry_pre_instrument"): entry_point.load()() - for entry_point in entry_points().get("opentelemetry_instrumentor", []): + for entry_point in entry_points(group="opentelemetry_instrumentor"): if entry_point.name in package_to_exclude: _logger.debug( "Instrumentation skipped for library %s", entry_point.name @@ -115,14 +115,14 @@ def _load_instrumentors(distro): _logger.exception("Instrumenting of %s failed", entry_point.name) raise exc - for entry_point in entry_points().get("opentelemetry_post_instrument", []): + for entry_point in entry_points(group="opentelemetry_post_instrument"): entry_point.load()() def _load_configurators(): configurator_name = environ.get(OTEL_PYTHON_CONFIGURATOR, None) configured = None - for entry_point in entry_points().get("opentelemetry_configurator", []): + for entry_point in entry_points(group="opentelemetry_configurator"): if configured is not None: _logger.warning( "Configuration of %s not loaded, %s already loaded", diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 1ea4e9a3a4..13f15de336 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -1,8 +1,8 @@ from logging import getLogger from typing import Collection, Optional -from packaging.requirements import Requirement -from importlib.metadata import PackageNotFoundError, Distribution, requires, version +from packaging.requirements import Requirement, InvalidRequirement +from importlib.metadata import PackageNotFoundError, Distribution, version logger = getLogger(__name__) @@ -22,30 +22,43 @@ def __str__(self): def get_dist_dependency_conflicts( dist: Distribution, ) -> Optional[DependencyConflict]: - main_deps = dist.requires instrumentation_deps = [] - for dep in requires(("instruments",)): - if dep not in main_deps: - # we set marker to none so string representation of the dependency looks like - # requests ~= 1.0 - # instead of - # requests ~= 1.0; extra = "instruments" - # which does not work with `get_distribution()` - dep.marker = None - instrumentation_deps.append(str(dep)) + extra = "extra" + instruments = "instruments" + instruments_marker = {extra: instruments} + for dep in dist.requires: + if extra not in dep or instruments not in dep: + continue + + req = Requirement(dep) + if req.marker.evaluate(instruments_marker): + instrumentation_deps.append(req) return get_dependency_conflicts(instrumentation_deps) def get_dependency_conflicts( - deps: Collection[str], + deps: Collection[str, Requirement], ) -> Optional[DependencyConflict]: for dep in deps: - req = Requirement(dep) + if isinstance(dep, Requirement): + req = dep + else: + try: + req = Requirement(dep) + except InvalidRequirement as exc: + logger.warning( + 'error parsing dependency, reporting as a conflict: "%s" - %s', + dep, + exc, + ) + return DependencyConflict(dep) + try: dist_version = version(req.name) except PackageNotFoundError: - return DependencyConflict(req.name) - if not req.specifier.filter(dist_version): - return DependencyConflict(req.name) + return DependencyConflict(dep) + + if not req.specifier.contains(dist_version): + return DependencyConflict(dep, f"{req.name} {dist_version}") return None diff --git a/opentelemetry-instrumentation/tests/test_dependencies.py b/opentelemetry-instrumentation/tests/test_dependencies.py index 7f10d29a32..6b0caea548 100644 --- a/opentelemetry-instrumentation/tests/test_dependencies.py +++ b/opentelemetry-instrumentation/tests/test_dependencies.py @@ -15,6 +15,7 @@ # pylint: disable=protected-access from importlib.metadata import Distribution, requires +from packaging.requirements import Requirement, InvalidRequirement import pytest from opentelemetry.instrumentation.dependencies import ( @@ -29,9 +30,23 @@ class TestDependencyConflicts(TestBase): def test_get_dependency_conflicts_empty(self): self.assertIsNone(get_dependency_conflicts([])) + def test_get_dependency_conflicts_no_conflict_requirement(self): + req = Requirement("pytest") + self.assertIsNone(get_dependency_conflicts([req])) + def test_get_dependency_conflicts_no_conflict(self): self.assertIsNone(get_dependency_conflicts(["pytest"])) + def test_get_dependency_conflicts_not_installed_requirement(self): + req = Requirement("this-package-does-not-exist") + conflict = get_dependency_conflicts([req]) + self.assertTrue(conflict is not None) + self.assertTrue(isinstance(conflict, DependencyConflict)) + self.assertEqual( + str(conflict), + 'DependencyConflict: requested: "this-package-does-not-exist" but found: "None"', + ) + def test_get_dependency_conflicts_not_installed(self): conflict = get_dependency_conflicts(["this-package-does-not-exist"]) self.assertTrue(conflict is not None) @@ -58,9 +73,7 @@ def mock_requires(extras=()): ) return [] - dist = Distribution( - project_name="test-instrumentation", version="1.0" - ) + dist = Distribution() dist.requires = mock_requires conflict = get_dist_dependency_conflicts(dist) From e37a1eab29337be77a303306653b40a35f9e475c Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Mon, 26 Feb 2024 19:35:50 -0300 Subject: [PATCH 06/37] feat: update version importlib --- opentelemetry-instrumentation/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/pyproject.toml b/opentelemetry-instrumentation/pyproject.toml index a9435038bb..9b2fb5ac40 100644 --- a/opentelemetry-instrumentation/pyproject.toml +++ b/opentelemetry-instrumentation/pyproject.toml @@ -28,7 +28,7 @@ dependencies = [ "opentelemetry-api ~= 1.4", "opentelemetry-semantic-conventions >= 0.48b0", "wrapt >= 1.0.0, < 2.0.0", - "importlib-metadata >= 6.0, < 7.0", + "importlib-metadata >= 6.0, < 8.0", "packaging >= 18.0", ] From 333ee6bfa9c28557a4bae4373011bea0933205cf Mon Sep 17 00:00:00 2001 From: Rodrigo-Novas Date: Tue, 27 Aug 2024 12:24:22 -0300 Subject: [PATCH 07/37] refactor: add Union to collection type --- .../src/opentelemetry/instrumentation/dependencies.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 13f15de336..42f40caaeb 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -1,8 +1,8 @@ +from importlib.metadata import Distribution, PackageNotFoundError, version from logging import getLogger -from typing import Collection, Optional +from typing import Collection, Optional, Union -from packaging.requirements import Requirement, InvalidRequirement -from importlib.metadata import PackageNotFoundError, Distribution, version +from packaging.requirements import InvalidRequirement, Requirement logger = getLogger(__name__) @@ -38,7 +38,7 @@ def get_dist_dependency_conflicts( def get_dependency_conflicts( - deps: Collection[str, Requirement], + deps: Collection[Union[str, Requirement]], ) -> Optional[DependencyConflict]: for dep in deps: if isinstance(dep, Requirement): From 681ffccba380743b4c14527bcad0d55244a82dcf Mon Sep 17 00:00:00 2001 From: Rodrigo-Novas Date: Tue, 27 Aug 2024 14:38:27 -0300 Subject: [PATCH 08/37] refactor: add value and group on tests --- opentelemetry-instrumentation/tests/test_distro.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/tests/test_distro.py b/opentelemetry-instrumentation/tests/test_distro.py index 611b30048b..add23a3f39 100644 --- a/opentelemetry-instrumentation/tests/test_distro.py +++ b/opentelemetry-instrumentation/tests/test_distro.py @@ -51,7 +51,7 @@ def test_load_instrumentor(self): 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) From 609a9c0f67a55f0e46e57880c7d0fd275a7ba617 Mon Sep 17 00:00:00 2001 From: Rodrigo-Novas Date: Tue, 27 Aug 2024 18:20:55 -0300 Subject: [PATCH 09/37] feat: execute tox --- .../instrumentation/auto_instrumentation/__init__.py | 7 ++++--- .../instrumentation/auto_instrumentation/_load.py | 3 +-- .../src/opentelemetry/instrumentation/bootstrap.py | 8 ++++---- .../src/opentelemetry/instrumentation/dependencies.py | 2 +- .../src/opentelemetry/instrumentation/distro.py | 3 +-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index adea9e1f0c..8b7070b195 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -13,14 +13,13 @@ # limitations under the License. from argparse import REMAINDER, ArgumentParser +from importlib.metadata import entry_points from logging import getLogger from os import environ, execl, getcwd from os.path import abspath, dirname, pathsep from re import sub from shutil import which -from importlib.metadata import entry_points - from opentelemetry.instrumentation.version import __version__ _logger = getLogger(__name__) @@ -48,7 +47,9 @@ def run() -> None: argument_otel_environment_variable = {} - for entry_point in entry_points(group="opentelemetry_environment_variables"): + for entry_point in entry_points( + group="opentelemetry_environment_variables" + ): environment_variable_module = entry_point.load() for attribute in dir(environment_variable_module): diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 0f00fbbcb2..5186ff7835 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -12,11 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +from importlib.metadata import EntryPoint, distributions, entry_points from logging import getLogger from os import environ -from importlib.metadata import entry_points, EntryPoint, distributions - from opentelemetry.instrumentation.dependencies import ( get_dist_dependency_conflicts, ) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index 81316f9ecb..7ef3a4e778 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -15,6 +15,7 @@ import argparse import logging import sys +from importlib.metadata import PackageNotFoundError, version from subprocess import ( PIPE, CalledProcessError, @@ -24,7 +25,6 @@ ) from packaging.requirements import Requirement -from importlib.metadata import PackageNotFoundError, version from opentelemetry.instrumentation.bootstrap_gen import ( default_instrumentations, @@ -93,18 +93,18 @@ def _pip_check(): def _is_installed(req): req = Requirement(req) - + try: dist_version = version(req.name) except PackageNotFoundError: return False - + if not req.specifier.filter(dist_version): logger.warning( "instrumentation for package %s is available" " but version %s is installed. Skipping.", req, - dist_version + dist_version, ) return False return True diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 42f40caaeb..24fe669215 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -52,7 +52,7 @@ def get_dependency_conflicts( dep, exc, ) - return DependencyConflict(dep) + return DependencyConflict(dep) try: dist_version = version(req.name) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py index 274886f42f..297e21657f 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py @@ -18,9 +18,8 @@ """ from abc import ABC, abstractmethod -from logging import getLogger - from importlib.metadata import EntryPoint +from logging import getLogger from opentelemetry.instrumentation.instrumentor import BaseInstrumentor From d1d2bb50075c03853d62f044e011a18716b13b87 Mon Sep 17 00:00:00 2001 From: Rodrigo-Novas Date: Fri, 30 Aug 2024 15:18:35 -0300 Subject: [PATCH 10/37] chore: change to unreleased side --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 348a606204..662f9d61a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,12 +25,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-instrumentation-aiokafka` Wrap `AIOKafkaConsumer.getone()` instead of `AIOKafkaConsumer.__anext__` ([#2874](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2874)) +### Breaking changes + +- Deprecation of pkg_resource in favor of importlib.metadata + ([#2180](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2180)) + ## Version 1.27.0/0.48b0 (2024-08-28) ### Added -- Deprecation of pkg_resource in favor of importlib.metadata - ([#2180](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2180)) - `opentelemetry-instrumentation-kafka-python` Instrument temporary fork, kafka-python-ng inside kafka-python's instrumentation ([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537)) - `opentelemetry-instrumentation-asgi`, `opentelemetry-instrumentation-fastapi` Add ability to disable internal HTTP send and receive spans From 57fc3b736648a63f7811e8fdbd253c6fd31f9ad2 Mon Sep 17 00:00:00 2001 From: Rodrigo-Novas Date: Fri, 30 Aug 2024 16:08:30 -0300 Subject: [PATCH 11/37] chore: change issue number --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 662f9d61a1..a92c5a7308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking changes - Deprecation of pkg_resource in favor of importlib.metadata - ([#2180](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2180)) + ([#2181](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2181)) ## Version 1.27.0/0.48b0 (2024-08-28) From 2213c1ebd5914ac32fcd9760409bf5f28a62a660 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 4 Sep 2024 15:06:56 -0600 Subject: [PATCH 12/37] Update core SHA in tox.ini --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 5bf05d451f..f476d923a2 100644 --- a/tox.ini +++ b/tox.ini @@ -394,7 +394,8 @@ allowlist_externals = setenv = ; override CORE_REPO_SHA via env variable when testing other branches/commits than main ; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e - CORE_REPO_SHA={env:CORE_REPO_SHA:main} + ; CORE_REPO_SHA={env:CORE_REPO_SHA:main} + CORE_REPO_SHA=71dc0d2a33c7656e53e5cac0ebf1af95f3b5b9f9 CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA} commands_pre = From 9c7519ced52ace1bacccbc0c04724cc51606535b Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 4 Sep 2024 15:31:03 -0600 Subject: [PATCH 13/37] wop --- .github/workflows/lint_0.yml | 2 +- .github/workflows/misc_0.yml | 2 +- .github/workflows/test_0.yml | 2 +- .github/workflows/test_1.yml | 2 +- tox.ini | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint_0.yml b/.github/workflows/lint_0.yml index 2236dc422c..09c31df507 100644 --- a/.github/workflows/lint_0.yml +++ b/.github/workflows/lint_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: main + CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/misc_0.yml b/.github/workflows/misc_0.yml index edb96b60d1..74562644ce 100644 --- a/.github/workflows/misc_0.yml +++ b/.github/workflows/misc_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: main + CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/test_0.yml b/.github/workflows/test_0.yml index d251737227..b769f590a1 100644 --- a/.github/workflows/test_0.yml +++ b/.github/workflows/test_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: main + CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml index 30ca4e67d2..42e28a3938 100644 --- a/.github/workflows/test_1.yml +++ b/.github/workflows/test_1.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: main + CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/tox.ini b/tox.ini index f476d923a2..7b05b5090b 100644 --- a/tox.ini +++ b/tox.ini @@ -395,7 +395,7 @@ setenv = ; override CORE_REPO_SHA via env variable when testing other branches/commits than main ; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e ; CORE_REPO_SHA={env:CORE_REPO_SHA:main} - CORE_REPO_SHA=71dc0d2a33c7656e53e5cac0ebf1af95f3b5b9f9 + CORE_REPO_SHA=67b33673458459ec8edc07d1054db3395afbfaff CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA} commands_pre = From ca037f4c82012a2a52c592bfa6e4d62a3d9a75bc Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 4 Sep 2024 18:23:13 -0600 Subject: [PATCH 14/37] Update core repo sha again --- .github/workflows/lint_0.yml | 2 +- .github/workflows/misc_0.yml | 2 +- .github/workflows/test_0.yml | 2 +- .github/workflows/test_1.yml | 2 +- opentelemetry-instrumentation/pyproject.toml | 1 - .../instrumentation/auto_instrumentation/__init__.py | 2 +- .../instrumentation/auto_instrumentation/_load.py | 4 +++- tox.ini | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint_0.yml b/.github/workflows/lint_0.yml index 09c31df507..f786043113 100644 --- a/.github/workflows/lint_0.yml +++ b/.github/workflows/lint_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff + CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/misc_0.yml b/.github/workflows/misc_0.yml index 74562644ce..9c4e427d70 100644 --- a/.github/workflows/misc_0.yml +++ b/.github/workflows/misc_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff + CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/test_0.yml b/.github/workflows/test_0.yml index b769f590a1..cf491bca33 100644 --- a/.github/workflows/test_0.yml +++ b/.github/workflows/test_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff + CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml index 42e28a3938..21801d2a71 100644 --- a/.github/workflows/test_1.yml +++ b/.github/workflows/test_1.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 67b33673458459ec8edc07d1054db3395afbfaff + CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/opentelemetry-instrumentation/pyproject.toml b/opentelemetry-instrumentation/pyproject.toml index 9b2fb5ac40..2bdfd1dbe6 100644 --- a/opentelemetry-instrumentation/pyproject.toml +++ b/opentelemetry-instrumentation/pyproject.toml @@ -28,7 +28,6 @@ dependencies = [ "opentelemetry-api ~= 1.4", "opentelemetry-semantic-conventions >= 0.48b0", "wrapt >= 1.0.0, < 2.0.0", - "importlib-metadata >= 6.0, < 8.0", "packaging >= 18.0", ] diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index 8b7070b195..22a2e03464 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -13,7 +13,7 @@ # limitations under the License. from argparse import REMAINDER, ArgumentParser -from importlib.metadata import entry_points +from opentelemetry.util._importlib_metadata import entry_points from logging import getLogger from os import environ, execl, getcwd from os.path import abspath, dirname, pathsep diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 5186ff7835..ec6244d410 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -from importlib.metadata import EntryPoint, distributions, entry_points +from opentelemetry.util._importlib_metadata import ( + EntryPoint, distributions, entry_points +) from logging import getLogger from os import environ diff --git a/tox.ini b/tox.ini index 7b05b5090b..547ca0e987 100644 --- a/tox.ini +++ b/tox.ini @@ -395,7 +395,7 @@ setenv = ; override CORE_REPO_SHA via env variable when testing other branches/commits than main ; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e ; CORE_REPO_SHA={env:CORE_REPO_SHA:main} - CORE_REPO_SHA=67b33673458459ec8edc07d1054db3395afbfaff + CORE_REPO_SHA=04e2d7a14dec5822ba78754b2ee2542797f8fe01 CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA} commands_pre = From ebfaf17e7f4bc5c17a9f45a3484d1293adf14f51 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 4 Sep 2024 18:30:52 -0600 Subject: [PATCH 15/37] Use opentelemertry importlib metadata --- .../opentelemetry/instrumentation/bootstrap.py | 4 +++- .../instrumentation/dependencies.py | 18 +++++++++++++++++- .../opentelemetry/instrumentation/distro.py | 2 +- .../tests/test_dependencies.py | 8 ++++---- .../tests/test_distro.py | 2 +- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index 7ef3a4e778..aae56648e0 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -15,7 +15,9 @@ import argparse import logging import sys -from importlib.metadata import PackageNotFoundError, version +from opentelemetry.util._importlib_metadata import ( + PackageNotFoundError, version +) from subprocess import ( PIPE, CalledProcessError, diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 24fe669215..6e9379fb8c 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -1,4 +1,20 @@ -from importlib.metadata import Distribution, PackageNotFoundError, version +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from opentelemetry.util._importlib_metadata import ( + Distribution, PackageNotFoundError, version +) from logging import getLogger from typing import Collection, Optional, Union diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py index 297e21657f..ed7a3bf3d4 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py @@ -18,7 +18,7 @@ """ from abc import ABC, abstractmethod -from importlib.metadata import EntryPoint +from opentelemetry.util._importlib_metadata import EntryPoint from logging import getLogger from opentelemetry.instrumentation.instrumentor import BaseInstrumentor diff --git a/opentelemetry-instrumentation/tests/test_dependencies.py b/opentelemetry-instrumentation/tests/test_dependencies.py index 6b0caea548..7448dec4e0 100644 --- a/opentelemetry-instrumentation/tests/test_dependencies.py +++ b/opentelemetry-instrumentation/tests/test_dependencies.py @@ -14,8 +14,8 @@ # pylint: disable=protected-access -from importlib.metadata import Distribution, requires -from packaging.requirements import Requirement, InvalidRequirement +from opentelemetry.util._importlib_metadata import Distribution, requires +from packaging.requirements import Requirement import pytest from opentelemetry.instrumentation.dependencies import ( @@ -69,8 +69,8 @@ def test_get_dist_dependency_conflicts(self): def mock_requires(extras=()): if "instruments" in extras: return requires( - 'test-pkg ~= 1.0; extra == "instruments"' - ) + 'test-pkg ~= 1.0; extra == "instruments"' + ) return [] dist = Distribution() diff --git a/opentelemetry-instrumentation/tests/test_distro.py b/opentelemetry-instrumentation/tests/test_distro.py index add23a3f39..8f937370a2 100644 --- a/opentelemetry-instrumentation/tests/test_distro.py +++ b/opentelemetry-instrumentation/tests/test_distro.py @@ -15,7 +15,7 @@ from unittest import TestCase -from importlib.metadata import EntryPoint +from opentelemetry.util._importlib_metadata import EntryPoint from opentelemetry.instrumentation.distro import BaseDistro from opentelemetry.instrumentation.instrumentor import BaseInstrumentor From 9229c6e2c05731fcb1738559845b95ff5a7dbc2d Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 5 Sep 2024 15:05:40 -0600 Subject: [PATCH 16/37] Remove importlib-metadata from test requirements --- .../test-requirements.txt | 1 - .../opentelemetry-exporter-richconsole/test-requirements.txt | 1 - .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - .../test-requirements-2.txt | 1 - .../test-requirements-3.txt | 1 - .../test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-aiopg/test-requirements.txt | 1 - .../opentelemetry-instrumentation-asgi/test-requirements.txt | 1 - .../opentelemetry-instrumentation-asyncio/test-requirements.txt | 1 - .../opentelemetry-instrumentation-asyncpg/test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-boto/test-requirements.txt | 1 - .../opentelemetry-instrumentation-boto3sqs/test-requirements.txt | 1 - .../opentelemetry-instrumentation-botocore/test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-celery/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-celery/test-requirements-1.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-dbapi/test-requirements.txt | 1 - .../opentelemetry-instrumentation-django/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-django/test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-django/test-requirements-2.txt | 1 - .../opentelemetry-instrumentation-django/test-requirements-3.txt | 1 - .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - .../test-requirements-2.txt | 1 - .../opentelemetry-instrumentation-falcon/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-falcon/test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-falcon/test-requirements-2.txt | 1 - .../opentelemetry-instrumentation-fastapi/test-requirements.txt | 1 - .../opentelemetry-instrumentation-flask/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-flask/test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-flask/test-requirements-2.txt | 1 - .../opentelemetry-instrumentation-grpc/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-grpc/test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-httpx/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-httpx/test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-jinja2/test-requirements.txt | 1 - .../test-requirements-ng.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-logging/test-requirements.txt | 1 - .../opentelemetry-instrumentation-mysql/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-mysql/test-requirements-1.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-pika/test-requirements-0.txt | 1 - .../opentelemetry-instrumentation-pika/test-requirements-1.txt | 1 - .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-psycopg2/test-requirements.txt | 1 - .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - .../test-requirements-2.txt | 1 - .../test-requirements-3.txt | 1 - .../test-requirements-4.txt | 1 - .../opentelemetry-instrumentation-pymongo/test-requirements.txt | 1 - .../opentelemetry-instrumentation-pymysql/test-requirements.txt | 1 - .../opentelemetry-instrumentation-pyramid/test-requirements.txt | 1 - .../opentelemetry-instrumentation-redis/test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-requests/test-requirements.txt | 1 - .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-sqlite3/test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-tornado/test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-instrumentation-urllib/test-requirements.txt | 1 - .../test-requirements-0.txt | 1 - .../test-requirements-1.txt | 1 - .../opentelemetry-instrumentation-wsgi/test-requirements.txt | 1 - opentelemetry-distro/test-requirements.txt | 1 - opentelemetry-instrumentation/test-requirements.txt | 1 - .../opentelemetry-propagator-aws-xray/test-requirements.txt | 1 - .../opentelemetry-propagator-ot-trace/test-requirements.txt | 1 - .../opentelemetry-resource-detector-azure/test-requirements.txt | 1 - .../test-requirements.txt | 1 - .../opentelemetry-sdk-extension-aws/test-requirements.txt | 1 - util/opentelemetry-util-http/test-requirements.txt | 1 - 82 files changed, 82 deletions(-) diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt b/exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt index 318e1e68d5..20d42eb4c6 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt @@ -6,7 +6,6 @@ cramjam==2.1.0; platform_python_implementation == "PyPy" cramjam==2.8.1; platform_python_implementation != "PyPy" Deprecated==1.2.14 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/exporter/opentelemetry-exporter-richconsole/test-requirements.txt b/exporter/opentelemetry-exporter-richconsole/test-requirements.txt index a63c91d0d8..fb9ccfdb7e 100644 --- a/exporter/opentelemetry-exporter-richconsole/test-requirements.txt +++ b/exporter/opentelemetry-exporter-richconsole/test-requirements.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 flaky==3.7.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 markdown-it-py==3.0.0 mdurl==0.1.2 diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-0.txt index 26c7046817..c2847c672c 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-0.txt @@ -3,7 +3,6 @@ aiormq==6.2.3 asgiref==3.8.1 Deprecated==1.2.14 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 multidict==6.0.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-1.txt index fac907831a..7c12b25ea4 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-1.txt @@ -3,7 +3,6 @@ aiormq==6.6.4 asgiref==3.8.1 Deprecated==1.2.14 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 multidict==6.0.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-2.txt index ad807173e8..3a4c21b3f7 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-2.txt @@ -3,7 +3,6 @@ aiormq==6.7.1 asgiref==3.8.1 Deprecated==1.2.14 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 multidict==6.0.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-3.txt b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-3.txt index 766cc6cf86..f5b8fdf345 100644 --- a/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-3.txt +++ b/instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-3.txt @@ -3,7 +3,6 @@ aiormq==6.8.0 asgiref==3.8.1 Deprecated==1.2.14 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 multidict==6.0.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt index f4da0edc25..8a0c88f805 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt @@ -11,7 +11,6 @@ Flask==3.0.2 frozenlist==1.4.1 http_server_mock==1.7 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 itsdangerous==2.1.2 Jinja2==3.1.4 diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt index d84eccb649..d492daf3c6 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt @@ -5,7 +5,6 @@ async-timeout==4.0.3 Deprecated==1.2.14 frozenlist==1.4.1 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 multidict==6.0.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-aiopg/test-requirements.txt index df527586f7..58669a50f9 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-aiopg/test-requirements.txt @@ -2,7 +2,6 @@ aiopg==1.4.0 asgiref==3.8.1 async-timeout==4.0.3 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt index de88049226..4b87261ffb 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-asyncio/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-asyncio/test-requirements.txt index 190e1cbe02..4f1877dd43 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncio/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-asyncio/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-asyncpg/test-requirements.txt index bb41329e66..c1a45c5887 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/test-requirements.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 async-timeout==4.0.3 asyncpg==0.29.0 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-aws-lambda/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-aws-lambda/test-requirements.txt index a80527dd36..75c3a56b62 100644 --- a/instrumentation/opentelemetry-instrumentation-aws-lambda/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-aws-lambda/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-boto/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-boto/test-requirements.txt index 41c228a1fe..bde6a42031 100644 --- a/instrumentation/opentelemetry-instrumentation-boto/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-boto/test-requirements.txt @@ -9,7 +9,6 @@ cryptography==43.0.1 Deprecated==1.2.14 docker==7.0.0 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 Jinja2==3.1.4 jmespath==1.0.1 diff --git a/instrumentation/opentelemetry-instrumentation-boto3sqs/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-boto3sqs/test-requirements.txt index dfa17c79a7..5adcd8ad15 100644 --- a/instrumentation/opentelemetry-instrumentation-boto3sqs/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-boto3sqs/test-requirements.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 boto3==1.34.44 botocore==1.34.44 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 jmespath==1.0.1 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-botocore/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-botocore/test-requirements.txt index e5e698c1cf..5253cf3bba 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-botocore/test-requirements.txt @@ -9,7 +9,6 @@ cryptography==43.0.1 Deprecated==1.2.14 docker==7.0.0 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 Jinja2==3.1.4 jmespath==1.0.1 diff --git a/instrumentation/opentelemetry-instrumentation-cassandra/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-cassandra/test-requirements.txt index 25bf51f2a5..3105aae550 100644 --- a/instrumentation/opentelemetry-instrumentation-cassandra/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-cassandra/test-requirements.txt @@ -4,7 +4,6 @@ pyasyncore==1.0.4 # for python 3.13 (should removed when cassandra-driver repla click==8.1.7 Deprecated==1.2.14 geomet==0.2.1.post1 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-celery/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-celery/test-requirements-0.txt index 1e018aae6e..811d805642 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-celery/test-requirements-0.txt @@ -8,7 +8,6 @@ click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.3.0 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 kombu==5.3.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt index c7d494aceb..5ef9e5750a 100644 --- a/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-celery/test-requirements-1.txt @@ -7,7 +7,6 @@ click-didyoumean==0.3.0 click-plugins==1.1.1 click-repl==0.3.0 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 kombu==5.3.5 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-confluent-kafka/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-confluent-kafka/test-requirements.txt index 7f389a12af..88b5bbe680 100644 --- a/instrumentation/opentelemetry-instrumentation-confluent-kafka/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-confluent-kafka/test-requirements.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 confluent-kafka==2.4.0 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-dbapi/test-requirements.txt index 1275616d45..a05fd86be5 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-dbapi/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-django/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-django/test-requirements-0.txt index 6c1b8337a4..f2375911d3 100644 --- a/instrumentation/opentelemetry-instrumentation-django/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-django/test-requirements-0.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 Django==2.2.28 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-django/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-django/test-requirements-1.txt index 357fd273f5..12f934acd4 100644 --- a/instrumentation/opentelemetry-instrumentation-django/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-django/test-requirements-1.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 Django==3.2.25 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt index 1d15b1336b..1ee4b0bfbf 100644 --- a/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-django/test-requirements-2.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 backports.zoneinfo==0.2.1 Deprecated==1.2.14 Django==4.2.15 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt b/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt index fa483e5ade..aba0b28fa2 100644 --- a/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt +++ b/instrumentation/opentelemetry-instrumentation-django/test-requirements-3.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 Django==4.2.15 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-0.txt index 977a440c85..7507078f84 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-0.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 Deprecated==1.2.14 elasticsearch==6.8.2 elasticsearch-dsl==6.4.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-1.txt index 44451736c8..fcd68f1c8e 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-1.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 Deprecated==1.2.14 elasticsearch==7.17.9 elasticsearch-dsl==7.4.1 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-2.txt index a02a9c0270..05af6f4d6c 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/test-requirements-2.txt @@ -3,7 +3,6 @@ Deprecated==1.2.14 elasticsearch==8.13.1 elasticsearch-dsl==8.13.1 elastic-transport==8.13.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-0.txt index 11a84eef70..7b0ce1caf9 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-0.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 falcon==1.4.1 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-1.txt index 9d646f3bbb..51f09a4c46 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-1.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 falcon==2.0.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-2.txt index d2a921eb87..cff1244cd0 100644 --- a/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-falcon/test-requirements-2.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 falcon==3.1.1 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt index 0417301559..0aab3a13e4 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-fastapi/test-requirements.txt @@ -10,7 +10,6 @@ h11==0.14.0 httpcore==1.0.4 httpx==0.27.0 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-flask/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-flask/test-requirements-0.txt index e6fa669267..d1c4687d83 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-flask/test-requirements-0.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 click==8.1.7 Deprecated==1.2.14 Flask==2.1.3 -importlib-metadata==6.11.0 iniconfig==2.0.0 itsdangerous==2.1.2 Jinja2==3.1.4 diff --git a/instrumentation/opentelemetry-instrumentation-flask/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-flask/test-requirements-1.txt index ecd3f680d8..37812de57e 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-flask/test-requirements-1.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 click==8.1.7 Deprecated==1.2.14 Flask==2.2.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 itsdangerous==2.1.2 Jinja2==3.1.4 diff --git a/instrumentation/opentelemetry-instrumentation-flask/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-flask/test-requirements-2.txt index da044a29e9..59edf6f540 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-flask/test-requirements-2.txt @@ -3,7 +3,6 @@ blinker==1.7.0 click==8.1.7 Deprecated==1.2.14 Flask==3.0.2 -importlib-metadata==6.11.0 iniconfig==2.0.0 itsdangerous==2.1.2 Jinja2==3.1.4 diff --git a/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-0.txt index cdea5fca4b..3e688b45c2 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-0.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 grpcio==1.62.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt index 9b2d088da3..7618e99dfa 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-grpc/test-requirements-1.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 grpcio==1.63.0 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-0.txt index 34eac9d10c..b663f4566b 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-0.txt @@ -7,7 +7,6 @@ h11==0.12.0 httpcore==0.13.7 httpx==0.18.2 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-1.txt index 93b4d024cb..4cd365d964 100644 --- a/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-httpx/test-requirements-1.txt @@ -7,7 +7,6 @@ h11==0.14.0 httpcore==1.0.4 httpx==0.27.0 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-jinja2/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-jinja2/test-requirements.txt index c7a30b8eb5..ffc92e3ffd 100644 --- a/instrumentation/opentelemetry-instrumentation-jinja2/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-jinja2/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 Jinja2==3.1.4 MarkupSafe==2.0.1 diff --git a/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements-ng.txt b/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements-ng.txt index 05e169a7e3..83cef19c4f 100644 --- a/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements-ng.txt +++ b/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements-ng.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 kafka-python-ng==2.2.2 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements.txt index a042ce833e..87752e3542 100644 --- a/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-kafka-python/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 kafka-python==2.0.2 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-logging/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-logging/test-requirements.txt index 600d066cc1..2512824c23 100644 --- a/instrumentation/opentelemetry-instrumentation-logging/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-logging/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt index 22e61d9df3..45fb95cb37 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-0.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 mysql-connector-python==8.3.0 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt index 1a58c16a05..0ca8efb64c 100644 --- a/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-mysql/test-requirements-1.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 mysql-connector-python==9.0.0 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-mysqlclient/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-mysqlclient/test-requirements.txt index 3dfa1b161d..0abcd23bd2 100644 --- a/instrumentation/opentelemetry-instrumentation-mysqlclient/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-mysqlclient/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 mysqlclient==2.2.4 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-pika/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-pika/test-requirements-0.txt index 871d4feac1..3e2f26b098 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-pika/test-requirements-0.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pika==0.13.1 diff --git a/instrumentation/opentelemetry-instrumentation-pika/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-pika/test-requirements-1.txt index b1c9e9094f..9ad521943f 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-pika/test-requirements-1.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pika==1.3.2 diff --git a/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-0.txt index 93ea09ca15..a68ae0b797 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-0.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 backports.zoneinfo==0.2.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-1.txt index 096d31599a..f45e3be149 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-psycopg/test-requirements-1.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-psycopg2/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-psycopg2/test-requirements.txt index 5ae59dc5ea..482c30222d 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg2/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-psycopg2/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-0.txt index 25e0f03bd6..d1b214c595 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-0.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-1.txt index 3005dc7aa8..64224bc7a5 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-1.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-2.txt b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-2.txt index 4c259345c6..d54b48ffea 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-2.txt +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-2.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-3.txt b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-3.txt index b0e2147639..509bdda5a6 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-3.txt +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-3.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-4.txt b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-4.txt index 36d0164961..93e1c041d5 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-4.txt +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/test-requirements-4.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymongo/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-pymongo/test-requirements.txt index a9319d5fdb..1e8a49d67d 100644 --- a/instrumentation/opentelemetry-instrumentation-pymongo/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-pymongo/test-requirements.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 dnspython==2.6.1 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pymysql/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-pymysql/test-requirements.txt index b1496da4e6..02018b0c5e 100644 --- a/instrumentation/opentelemetry-instrumentation-pymysql/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-pymysql/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-pyramid/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-pyramid/test-requirements.txt index 423838f23e..97815133f8 100644 --- a/instrumentation/opentelemetry-instrumentation-pyramid/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-pyramid/test-requirements.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 hupper==1.12.1 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 PasteDeploy==3.1.0 diff --git a/instrumentation/opentelemetry-instrumentation-redis/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-redis/test-requirements.txt index 4690006ef1..6beac4a9cc 100644 --- a/instrumentation/opentelemetry-instrumentation-redis/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-redis/test-requirements.txt @@ -2,7 +2,6 @@ asgiref==3.8.1 async-timeout==4.0.3 Deprecated==1.2.14 fakeredis==2.23.3 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-remoulade/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-remoulade/test-requirements.txt index a299e145a1..bfa53ed1f8 100644 --- a/instrumentation/opentelemetry-instrumentation-remoulade/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-remoulade/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-requests/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-requests/test-requirements.txt index a201206f0f..0b8d7ada10 100644 --- a/instrumentation/opentelemetry-instrumentation-requests/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-requests/test-requirements.txt @@ -4,7 +4,6 @@ charset-normalizer==3.3.2 Deprecated==1.2.14 httpretty==1.1.4 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-0.txt index cccdc3cb63..e3f87916c2 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-0.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 cffi==1.17.0 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-1.txt index b275f4e30e..885cee8c62 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/test-requirements-1.txt @@ -2,7 +2,6 @@ aiosqlite==0.20.0 asgiref==3.8.1 Deprecated==1.2.14 greenlet==3.0.3 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-sqlite3/test-requirements.txt index 2469d354d3..c6d1cb28e2 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-starlette/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-starlette/test-requirements.txt index 7f46b46981..3d756aa52e 100644 --- a/instrumentation/opentelemetry-instrumentation-starlette/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-starlette/test-requirements.txt @@ -8,7 +8,6 @@ h11==0.14.0 httpcore==1.0.4 httpx==0.27.0 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-system-metrics/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-system-metrics/test-requirements.txt index 710e4bdf7f..4b9b45b63d 100644 --- a/instrumentation/opentelemetry-instrumentation-system-metrics/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-system-metrics/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-threading/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-threading/test-requirements.txt index 84c3bb4d29..b40c591b6d 100644 --- a/instrumentation/opentelemetry-instrumentation-threading/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-threading/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-tornado/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-tornado/test-requirements.txt index 209c07e523..56a088ec62 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-tornado/test-requirements.txt @@ -7,7 +7,6 @@ Deprecated==1.2.14 Flask==3.0.2 http_server_mock==1.7 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 itsdangerous==2.1.2 Jinja2==3.1.4 diff --git a/instrumentation/opentelemetry-instrumentation-tortoiseorm/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-tortoiseorm/test-requirements.txt index 4ec6d195bf..c00ed195af 100644 --- a/instrumentation/opentelemetry-instrumentation-tortoiseorm/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-tortoiseorm/test-requirements.txt @@ -2,7 +2,6 @@ aiosqlite==0.17.0 annotated-types==0.7.0 asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 iso8601==1.1.0 packaging==24.0 diff --git a/instrumentation/opentelemetry-instrumentation-urllib/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-urllib/test-requirements.txt index 998ca77f6a..11fc627895 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-urllib/test-requirements.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 httpretty==1.1.4 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-0.txt b/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-0.txt index ad29eb1263..d85ac17f4f 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-0.txt +++ b/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-0.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 httpretty==1.1.4 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-1.txt b/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-1.txt index 48406b222d..14da384548 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-1.txt +++ b/instrumentation/opentelemetry-instrumentation-urllib3/test-requirements-1.txt @@ -1,7 +1,6 @@ asgiref==3.8.1 Deprecated==1.2.14 httpretty==1.1.4 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-wsgi/test-requirements.txt index acabba1abf..433d9e3201 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-wsgi/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/opentelemetry-distro/test-requirements.txt b/opentelemetry-distro/test-requirements.txt index 4f63e9e7b6..dba17daec3 100644 --- a/opentelemetry-distro/test-requirements.txt +++ b/opentelemetry-distro/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/opentelemetry-instrumentation/test-requirements.txt b/opentelemetry-instrumentation/test-requirements.txt index 24a5a56daf..943a45c8f4 100644 --- a/opentelemetry-instrumentation/test-requirements.txt +++ b/opentelemetry-instrumentation/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/propagator/opentelemetry-propagator-aws-xray/test-requirements.txt b/propagator/opentelemetry-propagator-aws-xray/test-requirements.txt index 8f5b428ba4..6cbca62382 100644 --- a/propagator/opentelemetry-propagator-aws-xray/test-requirements.txt +++ b/propagator/opentelemetry-propagator-aws-xray/test-requirements.txt @@ -3,7 +3,6 @@ certifi==2024.7.4 charset-normalizer==3.3.2 Deprecated==1.2.14 idna==3.7 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/propagator/opentelemetry-propagator-ot-trace/test-requirements.txt b/propagator/opentelemetry-propagator-ot-trace/test-requirements.txt index 4a97065065..379c534e26 100644 --- a/propagator/opentelemetry-propagator-ot-trace/test-requirements.txt +++ b/propagator/opentelemetry-propagator-ot-trace/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/resource/opentelemetry-resource-detector-azure/test-requirements.txt b/resource/opentelemetry-resource-detector-azure/test-requirements.txt index fe04c99490..353546f670 100644 --- a/resource/opentelemetry-resource-detector-azure/test-requirements.txt +++ b/resource/opentelemetry-resource-detector-azure/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/resource/opentelemetry-resource-detector-container/test-requirements.txt b/resource/opentelemetry-resource-detector-container/test-requirements.txt index 7cf0d49001..859005d42b 100644 --- a/resource/opentelemetry-resource-detector-container/test-requirements.txt +++ b/resource/opentelemetry-resource-detector-container/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt b/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt index 3b44b54a61..91a69c8d15 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt +++ b/sdk-extension/opentelemetry-sdk-extension-aws/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 diff --git a/util/opentelemetry-util-http/test-requirements.txt b/util/opentelemetry-util-http/test-requirements.txt index 7c71ae2ef3..ea2448bab9 100644 --- a/util/opentelemetry-util-http/test-requirements.txt +++ b/util/opentelemetry-util-http/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 From 7117c293d599484c85394bde10825e8b8b9b64aa Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Thu, 5 Sep 2024 15:08:00 -0600 Subject: [PATCH 17/37] Remove importlib-metadata dependency --- .../opentelemetry-instrumentation-flask/pyproject.toml | 1 - .../src/opentelemetry/instrumentation/flask/__init__.py | 4 ++-- tox.ini | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml b/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml index 0e74ca331f..8d02775824 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml +++ b/instrumentation/opentelemetry-instrumentation-flask/pyproject.toml @@ -31,7 +31,6 @@ dependencies = [ "opentelemetry-semantic-conventions == 0.49b0.dev", "opentelemetry-util-http == 0.49b0.dev", "packaging >= 21.0", - "importlib-metadata >= 4.0", ] [project.optional-dependencies] diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py index 192e044655..317624de7b 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -245,7 +245,7 @@ def response_hook(span: Span, status: str, response_headers: List): from typing import Collection import flask -import importlib_metadata as metadata +from opentelemetry._util.importlib_metadata import version from packaging import version as package_version import opentelemetry.instrumentation.wsgi as otel_wsgi @@ -288,7 +288,7 @@ def response_hook(span: Span, status: str, response_headers: List): _excluded_urls_from_env = get_excluded_urls("FLASK") -flask_version = metadata.version("flask") +flask_version = version("flask") if package_version.parse(flask_version) >= package_version.parse("2.2.0"): diff --git a/tox.ini b/tox.ini index 547ca0e987..7dbb5d0826 100644 --- a/tox.ini +++ b/tox.ini @@ -1235,7 +1235,6 @@ deps = greenlet==3.0.3 grpcio==1.62.1 idna==2.10 - importlib-metadata==6.11.0 iniconfig==2.0.0 jsonschema==3.2.0 kombu==5.3.5 From f62f35d3969ae33e24cfedcbc703166ed3107c8a Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 11:13:31 +0200 Subject: [PATCH 18/37] Back to main core repo --- .github/workflows/lint_0.yml | 2 +- .github/workflows/misc_0.yml | 2 +- .github/workflows/test_0.yml | 2 +- .github/workflows/test_1.yml | 2 +- tox.ini | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint_0.yml b/.github/workflows/lint_0.yml index f786043113..2236dc422c 100644 --- a/.github/workflows/lint_0.yml +++ b/.github/workflows/lint_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 + CORE_REPO_SHA: main CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/misc_0.yml b/.github/workflows/misc_0.yml index 9c4e427d70..edb96b60d1 100644 --- a/.github/workflows/misc_0.yml +++ b/.github/workflows/misc_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 + CORE_REPO_SHA: main CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/test_0.yml b/.github/workflows/test_0.yml index cf491bca33..d251737227 100644 --- a/.github/workflows/test_0.yml +++ b/.github/workflows/test_0.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 + CORE_REPO_SHA: main CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/.github/workflows/test_1.yml b/.github/workflows/test_1.yml index 21801d2a71..30ca4e67d2 100644 --- a/.github/workflows/test_1.yml +++ b/.github/workflows/test_1.yml @@ -10,7 +10,7 @@ on: pull_request: env: - CORE_REPO_SHA: 04e2d7a14dec5822ba78754b2ee2542797f8fe01 + CORE_REPO_SHA: main CONTRIB_REPO_SHA: main PIP_EXISTS_ACTION: w diff --git a/tox.ini b/tox.ini index 7dbb5d0826..cec851872e 100644 --- a/tox.ini +++ b/tox.ini @@ -394,8 +394,7 @@ allowlist_externals = setenv = ; override CORE_REPO_SHA via env variable when testing other branches/commits than main ; i.e: CORE_REPO_SHA=dde62cebffe519c35875af6d06fae053b3be65ec tox -e - ; CORE_REPO_SHA={env:CORE_REPO_SHA:main} - CORE_REPO_SHA=04e2d7a14dec5822ba78754b2ee2542797f8fe01 + CORE_REPO_SHA={env:CORE_REPO_SHA:main} CORE_REPO=git+https://github.com/open-telemetry/opentelemetry-python.git@{env:CORE_REPO_SHA} commands_pre = From 95954bbaf97476a0d04608b2ba907ded207173ff Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 11:24:29 +0200 Subject: [PATCH 19/37] opentelemetry-distro: stop using pkg_resources --- opentelemetry-distro/tests/test_distro.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/opentelemetry-distro/tests/test_distro.py b/opentelemetry-distro/tests/test_distro.py index ea7b9f08c8..9cd89eb039 100644 --- a/opentelemetry-distro/tests/test_distro.py +++ b/opentelemetry-distro/tests/test_distro.py @@ -16,21 +16,23 @@ import os from unittest import TestCase, mock -from pkg_resources import DistributionNotFound, require - from opentelemetry.distro import OpenTelemetryDistro from opentelemetry.environment_variables import ( OTEL_METRICS_EXPORTER, OTEL_TRACES_EXPORTER, ) from opentelemetry.sdk.environment_variables import OTEL_EXPORTER_OTLP_PROTOCOL +from opentelemetry.util._importlib_metadata import ( + PackageNotFoundError, + version, +) class TestDistribution(TestCase): def test_package_available(self): try: - require(["opentelemetry-distro"]) - except DistributionNotFound: + version("opentelemetry-distro") + except PackageNotFoundError: self.fail("opentelemetry-distro not installed") @mock.patch.dict("os.environ", {}, clear=True) From 86a8456b5d79ec0d2343b2b054400cb4165e15b7 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 11:31:49 +0200 Subject: [PATCH 20/37] opentelemetry-instrumentation-wsgi: try stop using pkg_resources --- .../tests/__init__.py | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-wsgi/tests/__init__.py b/instrumentation/opentelemetry-instrumentation-wsgi/tests/__init__.py index 8a3124243a..e69de29bb2 100644 --- a/instrumentation/opentelemetry-instrumentation-wsgi/tests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-wsgi/tests/__init__.py @@ -1,23 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import pkg_resources - -# IMPORTANT: Only the wsgi module needs this because it is always the first -# package that uses the `{rootdir}/*/tests/` path and gets installed by -# `eachdist.py` and according to `eachdist.ini`. - -# Naming the tests module as a namespace package ensures that -# relative imports will resolve properly for subsequent test packages, -# as it enables searching for a composite of multiple test modules. -pkg_resources.declare_namespace(__name__) From 79120e771d317fbc78778a69a43fca196e859fe2 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 11:36:42 +0200 Subject: [PATCH 21/37] opentelemetry-instrumentation-fastapi: stop using pkg_resources --- .../tests/test_fastapi_instrumentation.py | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index b8a6ef010e..0fd0cd46bd 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -16,13 +16,12 @@ import unittest from timeit import default_timer -from unittest.mock import Mock, patch +from unittest.mock import patch import fastapi from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware from fastapi.responses import JSONResponse from fastapi.testclient import TestClient -from pkg_resources import DistributionNotFound, iter_entry_points import opentelemetry.instrumentation.fastapi as otel_fastapi from opentelemetry import trace @@ -35,9 +34,6 @@ _server_duration_attrs_old, ) from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware -from opentelemetry.instrumentation.auto_instrumentation._load import ( - _load_instrumentors, -) from opentelemetry.sdk.metrics.export import ( HistogramDataPoint, NumberDataPoint, @@ -55,6 +51,10 @@ from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.test.globals_test import reset_trace_globals from opentelemetry.test.test_base import TestBase +from opentelemetry.util._importlib_metadata import ( + PackageNotFoundError, + entry_points, +) from opentelemetry.util.http import ( OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SANITIZE_FIELDS, OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_SERVER_REQUEST, @@ -1033,11 +1033,11 @@ def get_distribution_with_fastapi(*args, **kwargs): if dist == "fastapi~=0.58": # Value does not matter. Only whether an exception is thrown return None - raise DistributionNotFound() + raise PackageNotFoundError() def get_distribution_without_fastapi(*args, **kwargs): - raise DistributionNotFound() + raise PackageNotFoundError() class TestAutoInstrumentation(TestBaseAutoFastAPI): @@ -1048,16 +1048,10 @@ class TestAutoInstrumentation(TestBaseAutoFastAPI): """ def test_entry_point_exists(self): - eps = iter_entry_points("opentelemetry_instrumentor") - ep = next(eps) - self.assertEqual(ep.dist.key, "opentelemetry-instrumentation-fastapi") - self.assertEqual( - ep.module_name, "opentelemetry.instrumentation.fastapi" - ) - self.assertEqual(ep.attrs, ("FastAPIInstrumentor",)) + (ep,) = entry_points(group="opentelemetry_instrumentor") self.assertEqual(ep.name, "fastapi") - self.assertIsNone(next(eps, None)) + """ FIXME: get_distribution is gone @patch("opentelemetry.instrumentation.dependencies.get_distribution") def test_instruments_with_fastapi_installed(self, mock_get_distribution): mock_get_distribution.side_effect = get_distribution_with_fastapi @@ -1065,13 +1059,7 @@ def test_instruments_with_fastapi_installed(self, mock_get_distribution): _load_instrumentors(mock_distro) mock_get_distribution.assert_called_once_with("fastapi~=0.58") self.assertEqual(len(mock_distro.load_instrumentor.call_args_list), 1) - args = mock_distro.load_instrumentor.call_args.args - ep = args[0] - self.assertEqual(ep.dist.key, "opentelemetry-instrumentation-fastapi") - self.assertEqual( - ep.module_name, "opentelemetry.instrumentation.fastapi" - ) - self.assertEqual(ep.attrs, ("FastAPIInstrumentor",)) + (ep,) = mock_distro.load_instrumentor.call_args.args self.assertEqual(ep.name, "fastapi") @patch("opentelemetry.instrumentation.dependencies.get_distribution") @@ -1082,10 +1070,11 @@ def test_instruments_without_fastapi_installed( mock_distro = Mock() _load_instrumentors(mock_distro) mock_get_distribution.assert_called_once_with("fastapi~=0.58") - with self.assertRaises(DistributionNotFound): + with self.assertRaises(PackageNotFoundError): mock_get_distribution("fastapi~=0.58") self.assertEqual(len(mock_distro.load_instrumentor.call_args_list), 0) mock_distro.load_instrumentor.assert_not_called() + """ def _create_app(self): # instrumentation is handled by the instrument call From b5935630b63faa4abc51ebbb205bf357c93bd83c Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 11:38:32 +0200 Subject: [PATCH 22/37] opentelemetry-instrumentation-aiohttp-client: stop using pkg_resources --- .../tests/test_aiohttp_client_integration.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py index 8474bd436f..9ebb180de1 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py @@ -24,7 +24,6 @@ import aiohttp.test_utils import yarl from http_server_mock import HttpServerMock -from pkg_resources import iter_entry_points from opentelemetry import trace as trace_api from opentelemetry.instrumentation import aiohttp_client @@ -47,6 +46,7 @@ from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.test.test_base import TestBase from opentelemetry.trace import Span, StatusCode +from opentelemetry.util._importlib_metadata import entry_points def run_with_test_server( @@ -886,9 +886,9 @@ def response_hook( class TestLoadingAioHttpInstrumentor(unittest.TestCase): def test_loading_instrumentor(self): - entry_points = iter_entry_points( - "opentelemetry_instrumentor", "aiohttp-client" + (entry_point,) = entry_points( + group="opentelemetry_instrumentor", name="aiohttp-client" ) - instrumentor = next(entry_points).load()() + instrumentor = entry_point.load()() self.assertIsInstance(instrumentor, AioHttpClientInstrumentor) From ddc339cf5cd98e4726b11ffa87bce841a82dd3c1 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 15:57:18 +0200 Subject: [PATCH 23/37] opentelemetry-instrumentation: fix some tests --- .../tests/auto_instrumentation/test_load.py | 54 ------------------- .../tests/test_distro.py | 17 +++--- 2 files changed, 11 insertions(+), 60 deletions(-) diff --git a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py index 9b0941bafa..5e6efb46b1 100644 --- a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py +++ b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py @@ -32,12 +32,6 @@ class TestLoad(TestCase): @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_configurators( self, iter_mock ): # pylint: disable=no-self-use @@ -69,12 +63,6 @@ def test_load_configurators( @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_configurators_no_ep( self, iter_mock ): # pylint: disable=no-self-use @@ -88,12 +76,6 @@ def test_load_configurators_no_ep( @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_configurators_error(self, iter_mock): # Add multiple entry points but only specify the 2nd in the environment variable. ep_mock1 = Mock() @@ -121,12 +103,6 @@ def test_load_configurators_error(self, iter_mock): @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_distro(self, iter_mock, isinstance_mock): # Add multiple entry points but only specify the 2nd in the environment variable. ep_mock1 = Mock() @@ -160,12 +136,6 @@ def test_load_distro(self, iter_mock, isinstance_mock): @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_distro_not_distro( self, iter_mock, default_distro_mock, isinstance_mock ): @@ -198,12 +168,6 @@ def test_load_distro_not_distro( @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_distro_no_ep(self, iter_mock, default_distro_mock): iter_mock.return_value = () # Confirm default distro is used if there are no entry points. @@ -219,12 +183,6 @@ def test_load_distro_no_ep(self, iter_mock, default_distro_mock): @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_distro_error(self, iter_mock, isinstance_mock): ep_mock1 = Mock() ep_mock1.name = "custom_distro1" @@ -255,12 +213,6 @@ def test_load_distro_error(self, iter_mock, isinstance_mock): @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_instrumentors(self, iter_mock, dep_mock): # Mock opentelemetry_pre_instrument entry points # pylint: disable=too-many-locals @@ -335,12 +287,6 @@ def test_load_instrumentors(self, iter_mock, dep_mock): @patch( "opentelemetry.instrumentation.auto_instrumentation._load.entry_points" ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.distributions" - ) - @patch( - "opentelemetry.instrumentation.auto_instrumentation._load.EntryPoint" - ) def test_load_instrumentors_dep_conflict( self, iter_mock, dep_mock ): # pylint: disable=no-self-use diff --git a/opentelemetry-instrumentation/tests/test_distro.py b/opentelemetry-instrumentation/tests/test_distro.py index 8f937370a2..03a95614df 100644 --- a/opentelemetry-instrumentation/tests/test_distro.py +++ b/opentelemetry-instrumentation/tests/test_distro.py @@ -15,10 +15,9 @@ from unittest import TestCase -from opentelemetry.util._importlib_metadata 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 @@ def _uninstrument(self, **kwargs): 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 @@ def test_load_instrumentor(self): distro = MockDistro() instrumentor = MockInstrumetor() - entry_point = MockEntryPoint(MockInstrumetor, value="opentelemetry", group="opentelemetry_distro") + entry_point = MockEntryPoint( + "MockInstrumetor", + value="opentelemetry", + group="opentelemetry_distro", + ) self.assertFalse(instrumentor._is_instrumented_by_opentelemetry) distro.load_instrumentor(entry_point) From e63dc42a2072da1dc07e8ad939f858e50b21f102 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 16:02:07 +0200 Subject: [PATCH 24/37] opentelemetry-instrumentation: fix formatting --- .../instrumentation/auto_instrumentation/__init__.py | 2 +- .../instrumentation/auto_instrumentation/_load.py | 8 +++++--- .../src/opentelemetry/instrumentation/bootstrap.py | 7 ++++--- .../src/opentelemetry/instrumentation/dependencies.py | 9 ++++++--- .../src/opentelemetry/instrumentation/distro.py | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index 22a2e03464..963b3a6956 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -13,7 +13,6 @@ # limitations under the License. from argparse import REMAINDER, ArgumentParser -from opentelemetry.util._importlib_metadata import entry_points from logging import getLogger from os import environ, execl, getcwd from os.path import abspath, dirname, pathsep @@ -21,6 +20,7 @@ from shutil import which from opentelemetry.instrumentation.version import __version__ +from opentelemetry.util._importlib_metadata import entry_points _logger = getLogger(__name__) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index ec6244d410..2f1c478c43 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -12,9 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from opentelemetry.util._importlib_metadata import ( - EntryPoint, distributions, entry_points -) from logging import getLogger from os import environ @@ -28,6 +25,11 @@ OTEL_PYTHON_DISTRO, ) from opentelemetry.instrumentation.version import __version__ +from opentelemetry.util._importlib_metadata import ( + EntryPoint, + distributions, + entry_points, +) _logger = getLogger(__name__) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py index aae56648e0..02926ea5c4 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py @@ -15,9 +15,6 @@ import argparse import logging import sys -from opentelemetry.util._importlib_metadata import ( - PackageNotFoundError, version -) from subprocess import ( PIPE, CalledProcessError, @@ -33,6 +30,10 @@ libraries, ) from opentelemetry.instrumentation.version import __version__ +from opentelemetry.util._importlib_metadata import ( + PackageNotFoundError, + version, +) logger = logging.getLogger(__name__) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py index 6e9379fb8c..7ebc88d647 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py @@ -12,14 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from opentelemetry.util._importlib_metadata import ( - Distribution, PackageNotFoundError, version -) from logging import getLogger from typing import Collection, Optional, Union from packaging.requirements import InvalidRequirement, Requirement +from opentelemetry.util._importlib_metadata import ( + Distribution, + PackageNotFoundError, + version, +) + logger = getLogger(__name__) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py index ed7a3bf3d4..1bc847f988 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/distro.py @@ -18,10 +18,10 @@ """ from abc import ABC, abstractmethod -from opentelemetry.util._importlib_metadata import EntryPoint from logging import getLogger from opentelemetry.instrumentation.instrumentor import BaseInstrumentor +from opentelemetry.util._importlib_metadata import EntryPoint _LOG = getLogger(__name__) From 99c7bf262773a08848f89c362463f03146b93757 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 16:04:17 +0200 Subject: [PATCH 25/37] opentelemetry-instrumentation-flask: fix formatting --- .../src/opentelemetry/instrumentation/flask/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py index 317624de7b..e110bfaf93 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -245,11 +245,11 @@ def response_hook(span: Span, status: str, response_headers: List): from typing import Collection import flask -from opentelemetry._util.importlib_metadata import version from packaging import version as package_version import opentelemetry.instrumentation.wsgi as otel_wsgi from opentelemetry import context, trace +from opentelemetry._util.importlib_metadata import version from opentelemetry.instrumentation._semconv import ( _get_schema_url, _HTTPStabilityMode, From d2f2369a8a31dd698b8c94fa41c209311d6a2733 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 16:25:18 +0200 Subject: [PATCH 26/37] opentelemetry-instrumentation: fix another test --- .../tests/test_dependencies.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/opentelemetry-instrumentation/tests/test_dependencies.py b/opentelemetry-instrumentation/tests/test_dependencies.py index 7448dec4e0..bdee0f6f01 100644 --- a/opentelemetry-instrumentation/tests/test_dependencies.py +++ b/opentelemetry-instrumentation/tests/test_dependencies.py @@ -14,9 +14,8 @@ # pylint: disable=protected-access -from opentelemetry.util._importlib_metadata import Distribution, requires -from packaging.requirements import Requirement import pytest +from packaging.requirements import Requirement from opentelemetry.instrumentation.dependencies import ( DependencyConflict, @@ -24,6 +23,7 @@ get_dist_dependency_conflicts, ) from opentelemetry.test.test_base import TestBase +from opentelemetry.util._importlib_metadata import Distribution class TestDependencyConflicts(TestBase): @@ -66,20 +66,23 @@ def test_get_dependency_conflicts_mismatched_version(self): ) def test_get_dist_dependency_conflicts(self): - def mock_requires(extras=()): - if "instruments" in extras: - return requires( - 'test-pkg ~= 1.0; extra == "instruments"' - ) - return [] + class MockDistribution(Distribution): + def locate_file(self, path): + pass + + def read_text(self, filename): + pass + + @property + def requires(self): + return ['test-pkg ~= 1.0; extra == "instruments"'] - dist = Distribution() - dist.requires = mock_requires + dist = MockDistribution() conflict = get_dist_dependency_conflicts(dist) self.assertTrue(conflict is not None) self.assertTrue(isinstance(conflict, DependencyConflict)) self.assertEqual( str(conflict), - 'DependencyConflict: requested: "test-pkg~=1.0" but found: "None"', + 'DependencyConflict: requested: "test-pkg~=1.0; extra == "instruments"" but found: "None"', ) From 6c9ec8b8e360616ffa8a6c9fb5538a8e104a093a Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 17:51:19 +0200 Subject: [PATCH 27/37] fix flask --- .../src/opentelemetry/instrumentation/flask/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py index e110bfaf93..761fa3660f 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py @@ -249,7 +249,6 @@ def response_hook(span: Span, status: str, response_headers: List): import opentelemetry.instrumentation.wsgi as otel_wsgi from opentelemetry import context, trace -from opentelemetry._util.importlib_metadata import version from opentelemetry.instrumentation._semconv import ( _get_schema_url, _HTTPStabilityMode, @@ -272,6 +271,7 @@ def response_hook(span: Span, status: str, response_headers: List): HTTP_SERVER_REQUEST_DURATION, ) from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.util._importlib_metadata import version from opentelemetry.util.http import ( get_excluded_urls, parse_excluded_urls, From 24f307ff81878b5e501271332116b4cc61f4ac15 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 18:18:14 +0200 Subject: [PATCH 28/37] apply Arnatious cleanup for entry points dist cache --- .../auto_instrumentation/_load.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 2f1c478c43..0e410c7d25 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from functools import cached_property from logging import getLogger from os import environ @@ -35,26 +36,21 @@ class _EntryPointDistFinder: - def __int__(self): - self._mapping = None + @cached_property + def _mapping(self): + return { + self._key_for(ep): dist + for dist in distributions() + for ep in dist.entry_points + } def dist_for(self, entry_point: EntryPoint): dist = getattr(entry_point, "dist", None) if dist: return dist - if self._mapping is None: - self._mapping = { - self._key_for(ep): dist - for ep in dist.entry_points - for dist in distributions() - } - - return self._mapping.get(self._key_for(entry_point)) - - @staticmethod - def _key_for(entry_point: EntryPoint): - return f"{entry_point.group}:{entry_point.name}:{entry_point.value}" + key = f"{entry_point.group}:{entry_point.name}:{entry_point.value}" + return self._mapping.get(key) def _load_distro() -> BaseDistro: From 638fba62631a2867a1edc132ff121c46e238ec89 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 18:27:04 +0200 Subject: [PATCH 29/37] Fix previous commit --- .../instrumentation/auto_instrumentation/_load.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 0e410c7d25..8c2fefef3b 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -49,8 +49,11 @@ def dist_for(self, entry_point: EntryPoint): if dist: return dist - key = f"{entry_point.group}:{entry_point.name}:{entry_point.value}" - return self._mapping.get(key) + return self._mapping.get(self.key_for(entry_point)) + + @staticmethod + def _key_for(entry_point: EntryPoint): + return f"{entry_point.group}:{entry_point.name}:{entry_point.value}" def _load_distro() -> BaseDistro: From 744bb2519923a63c18fcb872ddf567f4a1657bda Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 13 Sep 2024 18:40:53 +0200 Subject: [PATCH 30/37] Fixup last commit --- .../opentelemetry/instrumentation/auto_instrumentation/_load.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py index 8c2fefef3b..7154238bb7 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py @@ -49,7 +49,7 @@ def dist_for(self, entry_point: EntryPoint): if dist: return dist - return self._mapping.get(self.key_for(entry_point)) + return self._mapping.get(self._key_for(entry_point)) @staticmethod def _key_for(entry_point: EntryPoint): From 226d02bef364e11c4b2dfcbf2d3227d6055e6758 Mon Sep 17 00:00:00 2001 From: Jeremy Voss Date: Fri, 20 Sep 2024 12:10:31 +0200 Subject: [PATCH 31/37] Update fastapi tests --- .../tests/test_fastapi_instrumentation.py | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index 0fd0cd46bd..e1fd32b5df 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -16,7 +16,7 @@ import unittest from timeit import default_timer -from unittest.mock import patch +from unittest.mock import Mock, patch import fastapi from fastapi.middleware.httpsredirect import HTTPSRedirectMiddleware @@ -34,6 +34,9 @@ _server_duration_attrs_old, ) from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware +from opentelemetry.instrumentation.auto_instrumentation._load import ( + _load_instrumentors, +) from opentelemetry.sdk.metrics.export import ( HistogramDataPoint, NumberDataPoint, @@ -1028,15 +1031,23 @@ def client_response_hook(send_span, scope, message): ) -def get_distribution_with_fastapi(*args, **kwargs): - dist = args[0] - if dist == "fastapi~=0.58": - # Value does not matter. Only whether an exception is thrown - return None +def mock_version_with_fastapi(*args, **kwargs): + req_name = args[0] + if req_name == "fastapi": + # TODO: Value now matters + return "0.58" raise PackageNotFoundError() -def get_distribution_without_fastapi(*args, **kwargs): +def mock_version_with_old_fastapi(*args, **kwargs): + req_name = args[0] + if req_name == "fastapi": + # TODO: Value now matters + return "0.57" + raise PackageNotFoundError() + + +def mock_version_without_fastapi(*args, **kwargs): raise PackageNotFoundError() @@ -1051,30 +1062,31 @@ def test_entry_point_exists(self): (ep,) = entry_points(group="opentelemetry_instrumentor") self.assertEqual(ep.name, "fastapi") - """ FIXME: get_distribution is gone - @patch("opentelemetry.instrumentation.dependencies.get_distribution") - def test_instruments_with_fastapi_installed(self, mock_get_distribution): - mock_get_distribution.side_effect = get_distribution_with_fastapi + @patch("opentelemetry.instrumentation.dependencies.version") + def test_instruments_with_fastapi_installed(self, mock_version): + mock_version.side_effect = mock_version_with_fastapi mock_distro = Mock() _load_instrumentors(mock_distro) - mock_get_distribution.assert_called_once_with("fastapi~=0.58") + mock_version.assert_called_once_with("fastapi") self.assertEqual(len(mock_distro.load_instrumentor.call_args_list), 1) (ep,) = mock_distro.load_instrumentor.call_args.args self.assertEqual(ep.name, "fastapi") - @patch("opentelemetry.instrumentation.dependencies.get_distribution") - def test_instruments_without_fastapi_installed( - self, mock_get_distribution - ): - mock_get_distribution.side_effect = get_distribution_without_fastapi + @patch("opentelemetry.instrumentation.dependencies.version") + def test_instruments_with_old_fastapi_installed(self, mock_version): + mock_version.side_effect = mock_version_with_old_fastapi mock_distro = Mock() _load_instrumentors(mock_distro) - mock_get_distribution.assert_called_once_with("fastapi~=0.58") - with self.assertRaises(PackageNotFoundError): - mock_get_distribution("fastapi~=0.58") - self.assertEqual(len(mock_distro.load_instrumentor.call_args_list), 0) + mock_version.assert_called_once_with("fastapi") + mock_distro.load_instrumentor.assert_not_called() + + @patch("opentelemetry.instrumentation.dependencies.version") + def test_instruments_without_fastapi_installed(self, mock_version): + mock_version.side_effect = mock_version_without_fastapi + mock_distro = Mock() + _load_instrumentors(mock_distro) + mock_version.assert_called_once_with("fastapi") mock_distro.load_instrumentor.assert_not_called() - """ def _create_app(self): # instrumentation is handled by the instrument call From e2db128c651064d51a68263d38842fdf115fdf29 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Fri, 20 Sep 2024 12:28:07 +0200 Subject: [PATCH 32/37] Please pylint --- .../tests/test_fastapi_instrumentation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index e1fd32b5df..bde91ccfcf 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -1073,7 +1073,9 @@ def test_instruments_with_fastapi_installed(self, mock_version): self.assertEqual(ep.name, "fastapi") @patch("opentelemetry.instrumentation.dependencies.version") - def test_instruments_with_old_fastapi_installed(self, mock_version): + def test_instruments_with_old_fastapi_installed( + self, mock_version + ): # pylint: disable=no-self-use mock_version.side_effect = mock_version_with_old_fastapi mock_distro = Mock() _load_instrumentors(mock_distro) @@ -1081,7 +1083,9 @@ def test_instruments_with_old_fastapi_installed(self, mock_version): mock_distro.load_instrumentor.assert_not_called() @patch("opentelemetry.instrumentation.dependencies.version") - def test_instruments_without_fastapi_installed(self, mock_version): + def test_instruments_without_fastapi_installed( + self, mock_version + ): # pylint: disable=no-self-use mock_version.side_effect = mock_version_without_fastapi mock_distro = Mock() _load_instrumentors(mock_distro) From 4a8055fbaa69a0ab2c7d4ad52295819489609a47 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 17 Oct 2024 10:42:44 +0200 Subject: [PATCH 33/37] Add some basic tests for the cache and some coverage for loading without mocks --- .../tests/auto_instrumentation/test_load.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py index 5e6efb46b1..df577f403a 100644 --- a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py +++ b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py @@ -23,6 +23,7 @@ OTEL_PYTHON_DISTRO, ) from opentelemetry.instrumentation.version import __version__ +from opentelemetry.util._importlib_metadata import entry_points class TestLoad(TestCase): @@ -314,3 +315,19 @@ def test_load_instrumentors_dep_conflict( ] ) distro_mock.load_instrumentor.assert_called_once() + + def test_load_instrumentors_no_entry_point_mocks(self): + distro_mock = Mock() + _load._load_instrumentors(distro_mock) + # this has no specific assert because it is run for every instrumentation + self.assertTrue(True) + + def test_entry_point_dist_finder(self): + entry_point_finder = _load._EntryPointDistFinder() + self.assertTrue(entry_point_finder._mapping) + entry_point = list( + entry_points(group="opentelemetry_environment_variables") + )[0] + self.assertTrue(entry_point) + entry_point_dist = entry_point_finder.dist_for(entry_point) + self.assertEqual(entry_point.dist, entry_point_dist) From d2d48a74ed03c8bce2add180d8143d205c82d516 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 17 Oct 2024 10:46:18 +0200 Subject: [PATCH 34/37] YOLO --- .../tests/__init__.py | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-test/tests/__init__.py b/instrumentation/opentelemetry-instrumentation-test/tests/__init__.py index a0b2062b52..e69de29bb2 100644 --- a/instrumentation/opentelemetry-instrumentation-test/tests/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-test/tests/__init__.py @@ -1,23 +0,0 @@ -# Copyright The OpenTelemetry Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import pkg_resources - -# IMPORTANT: Only the TEst module needs this because it is always the first -# package that uses the `{rootdir}/*/tests/` path and gets installed by -# `eachdist.py` and according to `eachdist.ini`. - -# Naming the tests module as a namespace package ensures that -# relative imports will resolve properly for subsequent test packages, -# as it enables searching for a composite of multiple test modules. -pkg_resources.declare_namespace(__name__) From c269629f9a45eec3cdf3ad3047061bda8f2b1b0a Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 17 Oct 2024 10:48:13 +0200 Subject: [PATCH 35/37] please pylint --- .../tests/auto_instrumentation/test_load.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py index df577f403a..8e428508b5 100644 --- a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py +++ b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py @@ -320,7 +320,7 @@ def test_load_instrumentors_no_entry_point_mocks(self): distro_mock = Mock() _load._load_instrumentors(distro_mock) # this has no specific assert because it is run for every instrumentation - self.assertTrue(True) + self.assertTrue(distro_mock) def test_entry_point_dist_finder(self): entry_point_finder = _load._EntryPointDistFinder() From 049ee35336f77a62248e369080319c6aeeca5c19 Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 17 Oct 2024 10:50:04 +0200 Subject: [PATCH 36/37] instrumentation/opentelemetry-instrumentation-test: drop importlib metadata from requiements --- .../opentelemetry-instrumentation-test/test-requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation/opentelemetry-instrumentation-test/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-test/test-requirements.txt index 743026e94a..e8f9e579c6 100644 --- a/instrumentation/opentelemetry-instrumentation-test/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-test/test-requirements.txt @@ -1,6 +1,5 @@ asgiref==3.8.1 Deprecated==1.2.14 -importlib-metadata==6.11.0 iniconfig==2.0.0 packaging==24.0 pluggy==1.5.0 From a1a76527aee765ff29977cd7691ffaabf009e5ee Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Thu, 17 Oct 2024 11:30:15 +0200 Subject: [PATCH 37/37] Cover more cases in entry point dist cache test --- .../tests/auto_instrumentation/test_load.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py index 8e428508b5..98bad3d9f9 100644 --- a/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py +++ b/opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py @@ -23,7 +23,7 @@ OTEL_PYTHON_DISTRO, ) from opentelemetry.instrumentation.version import __version__ -from opentelemetry.util._importlib_metadata import entry_points +from opentelemetry.util._importlib_metadata import EntryPoint, entry_points class TestLoad(TestCase): @@ -329,5 +329,23 @@ def test_entry_point_dist_finder(self): entry_points(group="opentelemetry_environment_variables") )[0] self.assertTrue(entry_point) + self.assertTrue(entry_point.dist) + + # this will not hit cache entry_point_dist = entry_point_finder.dist_for(entry_point) + self.assertTrue(entry_point_dist) + # dist are not comparable so we are sure we are not hitting the cache self.assertEqual(entry_point.dist, entry_point_dist) + + # this will hit cache + entry_point_without_dist = EntryPoint( + name=entry_point.name, + group=entry_point.group, + value=entry_point.value, + ) + self.assertIsNone(entry_point_without_dist.dist) + new_entry_point_dist = entry_point_finder.dist_for( + entry_point_without_dist + ) + # dist are not comparable, being truthy is enough + self.assertTrue(new_entry_point_dist)