opentelemetry Package

Microsoft OpenTelemetry Distro for Python.

Provides a single entry-point — <xref:use_microsoft_opentelemetry> — that initialises OpenTelemetry global providers (tracing, metrics, logging) and optionally configures Azure Monitor as an exporter.

Packages

a365

Agent365 observability for the Microsoft OpenTelemetry Distro.

Use use_microsoft_opentelemetry(enable_a365=True) to enable A365 telemetry. Import scope classes and data models from microsoft.opentelemetry.a365.core.

The symbols below are internal — kept only for backward compatibility with existing tests.

Functions

use_microsoft_opentelemetry

Configure OpenTelemetry with optional Azure Monitor support.

This function sets up the OpenTelemetry global providers (TracerProvider, MeterProvider, LoggerProvider) and optionally configures Azure Monitor as an exporter. Azure Monitor is off by default: enable it via enable_azure_monitor=True and provide a connection string.

use_microsoft_opentelemetry(**kwargs: object) -> None

Keyword-Only Parameters

Name Description
enable_azure_monitor

Enable Azure Monitor export. Defaults to False. Set to True to enable Azure Monitor setup.

azure_monitor_connection_string
str

Connection string for Application Insights resource.

azure_monitor_exporter_credential

Azure AD token credential for authentication.

azure_monitor_enable_live_metrics

Enable live metrics. Defaults to True.

azure_monitor_enable_performance_counters

Enable performance counters. Defaults to True.

azure_monitor_exporter_disable_offline_storage

Disable offline retry storage. Defaults to False.

azure_monitor_exporter_storage_directory
str

Custom directory for offline telemetry storage.

azure_monitor_browser_sdk_loader_config

Browser SDK loader configuration.

disable_logging

Disable the logging pipeline. Defaults to False.

disable_tracing

Disable the tracing pipeline. Defaults to False.

disable_metrics

Disable the metrics pipeline. Defaults to False.

resource

OpenTelemetry Resource.

span_processors

Additional span processors.

log_record_processors

Additional log record processors.

metric_readers

Additional metric readers.

views

Metric views.

logger_name
str

Logger name for log collection.

logging_formatter

Formatter for collected logs.

instrumentation_options

Per-library instrumentation enable/disable options.

enable_trace_based_sampling_for_logs

Enable trace-based sampling for logs.

enable_a365

Enable Agent365 trace export. Defaults to False.

a365_token_resolver

Optional callable (agent_id: str, tenant_id: str) -> str | None used to authenticate with the Agent365 endpoint. When omitted, DefaultAzureCredential is used. When both this and a365_contextual_token_resolver are set, the contextual resolver takes precedence.

a365_contextual_token_resolver

Optional callable (TokenResolverContext) -> str | None used to authenticate with the Agent365 endpoint. Receives rich context including the agentic user ID (AAD Object ID) extracted from span attributes. Takes precedence over a365_token_resolver when set.

a365_cluster_category
str

Cluster category for endpoint discovery. Also read from A365_CLUSTER_CATEGORY env var. Defaults to "prod".

a365_use_s2s_endpoint

Use the S2S endpoint. Also read from A365_USE_S2S_ENDPOINT env var. Defaults to False.

a365_suppress_invoke_agent_input

Strip input messages from InvokeAgent spans before export. Also read from A365_SUPPRESS_INVOKE_AGENT_INPUT env var. Defaults to False.

a365_enable_observability_exporter

Enable the A365 HTTP observability exporter. Also read from ENABLE_A365_OBSERVABILITY_EXPORTER env var. Defaults to False. Has no effect unless enable_a365=True.

a365_observability_scope_override
str

Override the authentication scope used when acquiring tokens for the A365 observability service. Equivalent to setting the A365_OBSERVABILITY_SCOPE_OVERRIDE environment variable. When provided, this kwarg overrides the env var.

a365_max_queue_size
int

Maximum queue size for the A365 batch span processor. Defaults to 2048 when omitted (BatchSpanProcessor default).

a365_scheduled_delay_ms
int

Delay between A365 export batches in milliseconds. Defaults to 5000 when omitted (BatchSpanProcessor default).

a365_exporter_timeout_ms
int

Timeout for a single A365 export operation in milliseconds. Defaults to 30000 when omitted (BatchSpanProcessor default).

a365_max_export_batch_size
int

Maximum batch size for a single A365 export operation. Defaults to 512 when omitted (BatchSpanProcessor default).

enable_console

Enable console exporter for traces, metrics, and logs (development only). Mirrors ExportTarget.Console from the .NET distro. Auto-enables when no other exporter is active (Azure Monitor off, OTLP off, A365 off). Defaults to False.

enable_spectra

Enable Spectra Collector sidecar export via OTLP. Defaults to False. Requires opentelemetry-exporter-otlp-proto-grpc for gRPC protocol; falls back to HTTP if gRPC is unavailable. Logs a warning and skips if neither exporter package is installed.

spectra_endpoint
str

Spectra sidecar OTLP endpoint. Also read from SPECTRA_ENDPOINT env var. Defaults to http://localhost:4317 for gRPC or http://localhost:4318 for HTTP.

spectra_protocol
str

OTLP protocol for Spectra — "grpc" or "http". Also read from SPECTRA_PROTOCOL env var. Defaults to "grpc".

spectra_insecure

Use insecure (no TLS) connection. Defaults to True (localhost sidecar).

enable_sensitive_data

Enable sensitive data recording (prompts, tool arguments, results) for the Agent Framework SDK instrumentation. Defaults to False.

Returns

Type Description