Skip to content

configure_azure_monitor attempts to use uninstalled libraries and logs tracebacks #40517

Open
@dylwil3

Description

@dylwil3
  • Package Name: azure-monitor-opentelemetry
  • Package Version: 1.6.7
  • Operating System:
  • Python Version: 3.12

Describe the bug
configure_azure_monitor attempts to setup instrumentations for libraries that are not installed

To Reproduce
Steps to reproduce the behavior:

  1. Install azure-monitor-opentelemetry without unnecessary dependencies (e.g. without django).
  2. Run configure_azure_monitor

Observe logs like:

Exception occurred when instrumenting: django.
Traceback (most recent call last):
  File "/app/.venv/lib/python3.12/site-packages/azure/monitor/opentelemetry/_configure.py", line 222, in _setup_instrumentations
    instrumentor: BaseInstrumentor = entry_point.load()
                                     ^^^^^^^^^^^^^^^^^^

Expected behavior
No tracebacks displayed for attempts to setup instrumentation for uninstalled libraries.

Additional context
The problem seems to be in this function:

def _setup_instrumentations(configurations: Dict[str, ConfigurationValue]):
# entry_point_finder = _EntryPointDistFinder()
# use pkg_resources for now until https://github.com/open-telemetry/opentelemetry-python/pull/3168 is merged
for entry_point in entry_points(group="opentelemetry_instrumentor"):
lib_name = entry_point.name

There used to be logic there for skipping setup on uninstalled libraries, but it was removed in #40463

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.MonitorMonitor, Monitor Ingestion, Monitor QueryOpenTelemetryOpenTelemetry instrumentation (not Monitor-specific)Service AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions