Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions microbootstrap/instruments/opentelemetry_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,16 @@ class BaseOpentelemetryInstrument(Instrument[OpentelemetryConfigT]):
ready_condition = "Provide all necessary config parameters"

def _load_instrumentors(self) -> None:
for entry_point in entry_points(group="opentelemetry_instrumentor"):
for entry_point in entry_points(group="opentelemetry_instrumentor"): # type: ignore[no-untyped-call]
if entry_point.name in self.instrument_config.opentelemetry_disabled_instrumentations:
LOGGER_OBJ.debug("Instrumentation skipped for library", entry_point_name=entry_point.name)
continue

try:
entry_point.load()().instrument(tracer_provider=self.tracer_provider)
LOGGER_OBJ.debug("Instrumented", entry_point_name=entry_point.name)
except DependencyConflictError as exc:
LOGGER_OBJ.debug("Skipping instrumentation", entry_point_name=entry_point.name, reason=exc.conflict)
continue
except ModuleNotFoundError as exc:
LOGGER_OBJ.debug("Skipping instrumentation", entry_point_name=entry_point.name, reason=exc.msg)
except ModuleNotFoundError:
continue
except ImportError:
LOGGER_OBJ.debug("Importing failed, skipping it", entry_point_name=entry_point.name)
Expand Down
3 changes: 2 additions & 1 deletion tests/instruments/test_opentelemetry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import typing
from unittest import mock
from unittest.mock import AsyncMock, MagicMock, Mock, patch

import fastapi
Expand Down Expand Up @@ -126,7 +127,7 @@ async def test_handler() -> None:
[
MagicMock(),
MagicMock(load=MagicMock(side_effect=ImportError)),
MagicMock(load=MagicMock(side_effect=DependencyConflictError("Hello"))),
MagicMock(load=MagicMock(side_effect=DependencyConflictError(mock.Mock()))),
MagicMock(load=MagicMock(side_effect=ModuleNotFoundError)),
],
"ok",
Expand Down
Loading