Azure Monitor Events Extension

0.1.0 · deprecated · verified Thu Apr 16

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

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to integrate OpenTelemetry with Azure Monitor using the recommended and actively maintained `azure-monitor-opentelemetry-distro` package, which has superseded `azure-monitor-events-extension`. It configures the OpenTelemetry SDK to send telemetry to Azure Application Insights using a connection string.

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.

view raw JSON →