Skip to content

Commit c174b80

Browse files
committed
hfjsakkdhfskdjhfsjakdh
1 parent ad81e4b commit c174b80

File tree

3 files changed

+4
-62
lines changed

3 files changed

+4
-62
lines changed

opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/_load.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from functools import cached_property
1615
from logging import getLogger
1716
from os import environ
1817

19-
from opentelemetry.instrumentation.dependencies import (
20-
get_dist_dependency_conflicts,
21-
DependencyConflictError
22-
)
18+
from opentelemetry.instrumentation.dependencies import DependencyConflictError
2319
from opentelemetry.instrumentation.distro import BaseDistro, DefaultDistro
2420
from opentelemetry.instrumentation.environment_variables import (
2521
OTEL_PYTHON_CONFIGURATOR,
2622
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS,
2723
OTEL_PYTHON_DISTRO,
2824
)
2925
from opentelemetry.instrumentation.version import __version__
30-
from opentelemetry.util._importlib_metadata import (
31-
EntryPoint,
32-
distributions,
33-
entry_points,
34-
)
26+
from opentelemetry.util._importlib_metadata import entry_points
3527

3628
_logger = getLogger(__name__)
3729

3830

39-
class _EntryPointDistFinder:
40-
@cached_property
41-
def _mapping(self):
42-
return {
43-
self._key_for(ep): dist
44-
for dist in distributions()
45-
for ep in dist.entry_points
46-
}
47-
48-
def dist_for(self, entry_point: EntryPoint):
49-
dist = getattr(entry_point, "dist", None)
50-
if dist:
51-
return dist
52-
53-
return self._mapping.get(self._key_for(entry_point))
54-
55-
@staticmethod
56-
def _key_for(entry_point: EntryPoint):
57-
return f"{entry_point.group}:{entry_point.name}:{entry_point.value}"
58-
59-
6031
def _load_distro() -> BaseDistro:
6132
distro_name = environ.get(OTEL_PYTHON_DISTRO, None)
6233
for entry_point in entry_points(group="opentelemetry_distro"):
@@ -84,7 +55,6 @@ def _load_distro() -> BaseDistro:
8455

8556
def _load_instrumentors(distro):
8657
package_to_exclude = environ.get(OTEL_PYTHON_DISABLED_INSTRUMENTATIONS, [])
87-
entry_point_finder = _EntryPointDistFinder()
8858
if isinstance(package_to_exclude, str):
8959
package_to_exclude = package_to_exclude.split(",")
9060
# to handle users entering "requests , flask" or "requests, flask" with spaces

opentelemetry-instrumentation/src/opentelemetry/instrumentation/dependencies.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def __init__(self, required: str | None, found: str | None = None):
3838

3939
def __str__(self):
4040
return f'DependencyConflict: requested: "{self.required}" but found: "{self.found}"'
41-
41+
42+
4243
class DependencyConflictError(Exception):
4344
def __init__(self, conflict: DependencyConflict):
4445
self.conflict = conflict

opentelemetry-instrumentation/tests/auto_instrumentation/test_load.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
OTEL_PYTHON_DISTRO,
2424
)
2525
from opentelemetry.instrumentation.version import __version__
26-
from opentelemetry.util._importlib_metadata import EntryPoint, entry_points
2726

2827

2928
class TestLoad(TestCase):
@@ -379,31 +378,3 @@ def test_load_instrumentors_no_entry_point_mocks(self):
379378
_load._load_instrumentors(distro_mock)
380379
# this has no specific assert because it is run for every instrumentation
381380
self.assertTrue(distro_mock)
382-
383-
def test_entry_point_dist_finder(self):
384-
entry_point_finder = _load._EntryPointDistFinder()
385-
self.assertTrue(entry_point_finder._mapping)
386-
entry_point = list(
387-
entry_points(group="opentelemetry_environment_variables")
388-
)[0]
389-
self.assertTrue(entry_point)
390-
self.assertTrue(entry_point.dist)
391-
392-
# this will not hit cache
393-
entry_point_dist = entry_point_finder.dist_for(entry_point)
394-
self.assertTrue(entry_point_dist)
395-
# dist are not comparable so we are sure we are not hitting the cache
396-
self.assertEqual(entry_point.dist, entry_point_dist)
397-
398-
# this will hit cache
399-
entry_point_without_dist = EntryPoint(
400-
name=entry_point.name,
401-
group=entry_point.group,
402-
value=entry_point.value,
403-
)
404-
self.assertIsNone(entry_point_without_dist.dist)
405-
new_entry_point_dist = entry_point_finder.dist_for(
406-
entry_point_without_dist
407-
)
408-
# dist are not comparable, being truthy is enough
409-
self.assertTrue(new_entry_point_dist)

0 commit comments

Comments
 (0)