Repository: open-telemetry/opentelemetry-python (language: python)

Issue:
Add missing symbols to `opentelemetry.util._importlib_metadata`
In order to fix this [contrib issue](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2181) properly (which means using `opentelemetry.util._importlib_metadata` instead of directly using `importlib.metadata`) we need more symbols to be present in `opentelemetry.util._importlib_metadata`.

Add those missing symbols.


Discussion / hints:

Fix patch:
diff --git a/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py b/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py
index cbf09f3ef8c..2457630ba22 100644
--- a/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py
+++ b/opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py
@@ -15,15 +15,23 @@
 # FIXME: Use importlib.metadata when support for 3.11 is dropped if the rest of
 # the supported versions at that time have the same API.
 from importlib_metadata import (  # type: ignore
+    Distribution,
     EntryPoint,
     EntryPoints,
+    PackageNotFoundError,
+    distributions,
     entry_points,
+    requires,
     version,
 )
 
-# The importlib-metadata library has introduced breaking changes before to its
-# API, this module is kept just to act as a layer between the
-# importlib-metadata library and our project if in any case it is necessary to
-# do so.
-
-__all__ = ["entry_points", "version", "EntryPoint", "EntryPoints"]
+__all__ = [
+    "entry_points",
+    "version",
+    "EntryPoint",
+    "EntryPoints",
+    "requires",
+    "Distribution",
+    "distributions",
+    "PackageNotFoundError",
+]


Test patch:
diff --git a/opentelemetry-api/tests/util/test__importlib_metadata.py b/opentelemetry-api/tests/util/test__importlib_metadata.py
index 92a4e7dd62a..dce949c47d8 100644
--- a/opentelemetry-api/tests/util/test__importlib_metadata.py
+++ b/opentelemetry-api/tests/util/test__importlib_metadata.py
@@ -19,6 +19,7 @@
 from opentelemetry.util._importlib_metadata import (
     entry_points as importlib_metadata_entry_points,
 )
+from opentelemetry.util._importlib_metadata import version
 
 
 class TestEntryPoints(TestCase):
@@ -106,3 +107,5 @@ def test_uniform_behavior(self):
         entry_points = importlib_metadata_entry_points(group="abc", name="abc")
         self.assertIsInstance(entry_points, EntryPoints)
         self.assertEqual(len(entry_points), 0)
+
+        self.assertIsInstance(version("opentelemetry-api"), str)