microsoft.opentelemetry package

Microsoft OpenTelemetry Distro for Python.

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

microsoft.opentelemetry.use_microsoft_opentelemetry(**kwargs)[source]

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.

Keyword Arguments:
  • enable_azure_monitor (bool) – 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 (bool) – Enable live metrics. Defaults to True.

  • azure_monitor_enable_performance_counters (bool) – Enable performance counters. Defaults to True.

  • azure_monitor_exporter_disable_offline_storage (bool) – 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 (dict) – Browser SDK loader configuration.

  • disable_logging (bool) – Disable the logging pipeline. Defaults to False.

  • disable_tracing (bool) – Disable the tracing pipeline. Defaults to False.

  • disable_metrics (bool) – Disable the metrics pipeline. Defaults to False.

  • resource – OpenTelemetry Resource.

  • span_processors (list) – Additional span processors.

  • log_record_processors (list) – Additional log record processors.

  • metric_readers (list) – Additional metric readers.

  • views (list) – Metric views.

  • logger_name (str) – Logger name for log collection.

  • logging_formatter – Formatter for collected logs.

  • instrumentation_options (dict) – Per-library instrumentation enable/disable options.

  • enable_trace_based_sampling_for_logs (bool) – Enable trace-based sampling for logs.

  • enable_a365 (bool) – 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.

  • a365_cluster_category (str) – Cluster category for endpoint discovery. Also read from A365_CLUSTER_CATEGORY env var. Defaults to "prod".

  • a365_use_s2s_endpoint (bool) – Use the S2S endpoint. Also read from A365_USE_S2S_ENDPOINT env var. Defaults to False.

  • a365_suppress_invoke_agent_input (bool) – 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 (bool) – 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 (bool) – 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 (bool) – 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 (bool) – Use insecure (no TLS) connection. Defaults to True (localhost sidecar).

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

Return type:

None

Subpackages