All skills
microsoft avatar

/azure-monitor-opentelemetry-exporter-py

@e19efc2
by microsoftmicrosoft/skills3.1k stars
351

Azure Monitor OpenTelemetry Exporter for Python. Use for low-level OpenTelemetry export to Application Insights. Triggers: "azure-monitor-opentelemetry-exporter", "AzureMonitorTraceExporter", "AzureMonitorMetricExporter", "AzureMonitorLogExporter".

Use this Skill: https://skilld.dev/gh/microsoft/skills/azure-monitor-opentelemetry-exporter-py

This session only. Nothing lands on disk.

referencesnon-hero-scenarios.md

≈756 tokens on demand. Your agent reads this file only when SKILL.md points to it.

azure-monitor-opentelemetry-exporter-py non-hero scenarios

These scenarios are intentionally separate from hero flows in SKILL.md. They cover secondary/advanced patterns typically used after the primary end-to-end path is working.

Azure AD Authentication

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

# Local dev: DefaultAzureCredential. In production, set AZURE_TOKEN_CREDENTIALS=prod or use a specific credential.
credential = DefaultAzureCredential()
# Or use a specific credential directly in production:
# See https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#credential-classes
# credential = ManagedIdentityCredential()

exporter = AzureMonitorTraceExporter(
    credential=credential
)

Sampling

Use ApplicationInsightsSampler for consistent sampling:

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
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.identity import DefaultAzureCredential
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

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

Disable Offline Storage

exporter = AzureMonitorTraceExporter(
    credential=DefaultAzureCredential(),
    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

Exporter Telemetry Type Application Insights Table
AzureMonitorTraceExporter Traces/Spans requests, dependencies, exceptions
AzureMonitorMetricExporter Metrics customMetrics, performanceCounters
AzureMonitorLogExporter Logs traces, customEvents

Configuration Options

Parameter Description Default
connection_string Application Insights connection string From env var
credential Azure credential for AAD auth None
disable_offline_storage Disable retry storage False
storage_directory Custom storage path Temp directory

Source: SKILL.md on GitHub

1 warning15d4 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill provides standard instructions for using the Azure Monitor OpenTelemetry Exporter for Python. It follows security best practices such as using managed identities for authentication and provides configuration for legitimate features like offline storage and sovereign clouds. No security issues were detected.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer7mo

    2/2 files flagged

Signed by skilld at e19efc2. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
Other metadata
metadata
{
  "author": "Microsoft",
  "version": "1.0.0",
  "package": "azure-monitor-opentelemetry-exporter"
}

README badge

README badge for microsoft/skills/azure-monitor-opentelemetry-exporter-py