Azure Monitor Events Extension
This package, `azure-monitor-events-extension`, is an older, likely superseded component for integrating Python applications with Azure Monitor. It has not been updated since its `0.1.0` release in 2021. For modern Python applications, it is highly recommended to use the OpenTelemetry-native packages `azure-monitor-opentelemetry-distro` and `azure-monitor-opentelemetry-exporter` for robust and up-to-date Azure Monitor integration.
Common errors
-
AttributeError: module 'azure_monitor_events_extension' has no attribute 'init'
cause Attempting to initialize or use `azure-monitor-events-extension` with an API pattern that either doesn't exist or is from a different, modern package.fixThis package is deprecated. For Azure Monitor integration, install `azure-monitor-opentelemetry-distro` and use `from azure.monitor.opentelemetry.distro import configure_opentelemetry` instead. -
Package 'azure-monitor-events-extension' conflicts with 'opentelemetry-sdk' version X.Y.Z
cause The `azure-monitor-events-extension` package likely depends on older, potentially incompatible versions of OpenTelemetry or other libraries, leading to dependency conflicts when installed with modern packages.fixThis package is deprecated. It is strongly recommended to uninstall `azure-monitor-events-extension` and use the officially supported `azure-monitor-opentelemetry-distro` and `azure-monitor-opentelemetry-exporter` for Azure Monitor integration.
Warnings
- breaking The `azure-monitor-events-extension` package is deprecated and considered abandoned. It has not received updates since its `0.1.0` release in 2021. Users should migrate to `azure-monitor-opentelemetry-distro` and `azure-monitor-opentelemetry-exporter` for current and supported Azure Monitor integration.
- gotcha Despite its name, `azure-monitor-events-extension` refers to an older, custom implementation, not the current OpenTelemetry-native approach. Attempting to use it alongside modern OpenTelemetry SDKs will likely lead to conflicts or non-functional telemetry.
- gotcha The package requires Python `>=3.7` but has not been tested or updated for newer Python versions (3.9, 3.10, 3.11, 3.12+). Compatibility with modern Python environments is not guaranteed.
Install
-
pip install azure-monitor-events-extension -
pip install azure-monitor-opentelemetry-distro
Imports
- configure_opentelemetry
from azure_monitor_events_extension import configure_opentelemetry
from azure.monitor.opentelemetry.distro import configure_opentelemetry
Quickstart
import os
from opentelemetry import trace
from azure.monitor.opentelemetry.distro import configure_opentelemetry
# NOTE: This quickstart demonstrates the recommended way using the *successor* library,
# `azure-monitor-opentelemetry-distro`, not the deprecated `azure-monitor-events-extension`.
# Configure OpenTelemetry to export to Azure Monitor
configure_opentelemetry(
connection_string=os.environ.get("APPLICATIONINSIGHTS_CONNECTION_STRING", "")
)
# Example usage with OpenTelemetry tracer
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("my-span"):
print("Hello from my-span!")
# In a real application, ensure the application stays alive long enough for telemetry to be sent.
# For example, a web framework automatically handles this. For a script, you might need
# to add a small delay or ensure there's ongoing activity.