New to Claude Skills? Learn how to install them →

sickn33 on GitHub

Azure Monitor OpenTelemetry Exporter

Free

Efficiently export telemetry data to Azure Application Insights.

Get this skill

Free · Opens the source repo

What Azure Monitor OpenTelemetry Exporter does

The Azure Monitor OpenTelemetry Exporter for Python is designed for developers looking to send telemetry data, including traces, metrics, and logs, directly to Azure Application Insights. This low-level exporter allows for fine-grained control over how telemetry data is collected and transmitted, making it suitable for custom OpenTelemetry pipelines. By utilizing this exporter, developers can ensure that their applications are monitored effectively, providing insights into performance and reliability.

Installation is straightforward, requiring only a simple pip install command. Once installed, users can configure the exporter using an Application Insights connection string, which can be set as an environment variable for convenience. The exporter supports various telemetry types, allowing developers to capture detailed traces, metrics, and logs from their applications. This flexibility is particularly valuable in production environments where monitoring is critical for maintaining application health.

The skill is particularly useful when developers need to implement a custom telemetry solution that goes beyond the default auto-instrumentation provided by the azure-monitor-opentelemetry package. It is also beneficial for those who require specific configurations, such as offline storage for retrying failed transmissions or Azure Active Directory authentication. Best practices are provided to guide users in configuring the exporter for optimal performance and reliability, ensuring that telemetry data is collected consistently and accurately.

Overall, this skill is ideal for Python developers who want to integrate OpenTelemetry with Azure Application Insights, providing them with the tools necessary to monitor their applications effectively and enhance their observability practices.

When to use it

Use this exporter when you need a custom OpenTelemetry pipeline or require detailed control over telemetry data.

When not to use it

Avoid this skill if you prefer the convenience of auto-instrumentation provided by the `azure-monitor-opentelemetry` package without customization.

What you can build with it

Custom Telemetry Pipelines

When you need to create a tailored telemetry pipeline that captures specific metrics and logs from your application.

Production Monitoring

In production environments where consistent and reliable telemetry data is crucial for application performance monitoring.

Azure AD Integration

When you want to leverage Azure Active Directory for secure authentication while exporting telemetry data.

How to install Azure Monitor OpenTelemetry Exporter

View source

1. Install with the skills CLI

npx skills add sickn33/agentic-awesome-skills/azure-monitor-opentelemetry-exporter-py --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by sickn33

Azure Monitor OpenTelemetry Exporter for Python

Low-level exporter for sending OpenTelemetry traces, metrics, and logs to Application Insights.

Installation

pip install azure-monitor-opentelemetry-exporter

Environment Variables

APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=xxx;IngestionEndpoint=https://xxx.in.applicationinsights.azure.com/

When to Use

ScenarioUse
Quick setup, auto-instrumentationazure-monitor-opentelemetry (distro)
Custom OpenTelemetry pipelineazure-monitor-opentelemetry-exporter (this)
Fine-grained control over telemetryazure-monitor-opentelemetry-exporter (this)

Trace Exporter

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

# Create exporter
exporter = AzureMonitorTraceExporter(
    connection_string="InstrumentationKey=xxx;..."
)

# Configure tracer provider
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
    BatchSpanProcessor(exporter)
)

# Use tracer
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("my-span"):
    print("Hello, World!")

Metric Exporter

from opentelemetry import metrics
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from azure.monitor.opentelemetry.exporter import AzureMonitorMetricExporter

# Create exporter
exporter = AzureMonitorMetricExporter(
    connection_string="InstrumentationKey=xxx;..."
)

# Configure meter provider
reader = PeriodicExportingMetricReader(exporter, export_interval_millis=60000)
metrics.set_meter_provider(MeterProvider(metric_readers=[reader]))

# Use meter
meter = metrics.get_meter(__name__)
counter = meter.create_counter("requests_total")
counter.add(1, {"route": "/api/users"})

Log Exporter

import logging
from opentelemetry._logs import set_logger_provider
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from azure.monitor.opentelemetry.exporter import AzureMonitorLogExporter

# Create exporter
exporter = AzureMonitorLogExporter(
    connection_string="InstrumentationKey=xxx;..."
)

# Configure logger provider
logger_provider = LoggerProvider()
logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))
set_logger_provider(logger_provider)

# Add handler to Python logging
handler = LoggingHandler(level=logging.INFO, logger_provider=logger_provider)
logging.getLogger().addHandler(handler)

# Use logging
logger = logging.getLogger(__name__)
logger.info("This will be sent to Application Insights")

From Environment Variable

Exporters read APPLICATIONINSIGHTS_CONNECTION_STRING automatically:

from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

# Connection string from environment
exporter = AzureMonitorTraceExporter()

Azure AD Authentication

from azure.identity import DefaultAzureCredential
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

exporter = AzureMonitorTraceExporter(
    credential=DefaultAzureCredential()
)

Sampling

Use ApplicationInsightsSampler for consistent sampling:

from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.sampling import ParentBasedTraceIdRatio
from azure.monitor.opentelemetry.exporter import ApplicationInsightsSampler

# Sample 10% of traces
sampler = ApplicationInsightsSampler(sampling_ratio=0.1)

trace.set_tracer_provider(TracerProvider(sampler=sampler))

Offline Storage

Configure offline storage for retry:

from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

exporter = AzureMonitorTraceExporter(
    connection_string="...",
    storage_directory="/path/to/storage",  # Custom storage path
    disable_offline_storage=False  # Enable retry (default)
)

Disable Offline Storage

exporter = AzureMonitorTraceExporter(
    connection_string="...",
    disable_offline_storage=True  # No retry on failure
)

Sovereign Clouds

from azure.identity import AzureAuthorityHosts, DefaultAzureCredential
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

# Azure Government
credential = DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)
exporter = AzureMonitorTraceExporter(
    connection_string="InstrumentationKey=xxx;IngestionEndpoint=https://xxx.in.applicationinsights.azure.us/",
    credential=credential
)

Exporter Types

ExporterTelemetry TypeApplication Insights Table
AzureMonitorTraceExporterTraces/Spansrequests, dependencies, exceptions
AzureMonitorMetricExporterMetricscustomMetrics, performanceCounters
AzureMonitorLogExporterLogstraces, customEvents

Configuration Options

ParameterDescriptionDefault
connection_stringApplication Insights connection stringFrom env var
credentialAzure credential for AAD authNone
disable_offline_storageDisable retry storageFalse
storage_directoryCustom storage pathTemp directory

Best Practices

  1. Use BatchSpanProcessor for production (not SimpleSpanProcessor)
  2. Use ApplicationInsightsSampler for consistent sampling across services
  3. Enable offline storage for reliability in production
  4. Use AAD authentication instead of instrumentation keys
  5. Set export intervals appropriate for your workload
  6. Use the distro (azure-monitor-opentelemetry) unless you need custom pipelines

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

Frequently asked questions about Azure Monitor OpenTelemetry Exporter

Similar skills