Microsoft Azure Core OpenTelemetry plugin Library for Python
Maintained. Last release 7 months ago, commits in 26 of the last 26 weeks. Weaker on issue handling and release cadence.
pip install azure-core-tracing-opentelemetryAzure Core Tracing OpenTelemetry client library for Python
Getting started
You can enable distributed tracing in Azure client libraries by configuring the OpenTelemetry SDK. OpenTelemetry is a popular open-source observability framework for generating, capturing, and collecting telemetry data for cloud-native software.
There are two key concepts related to tracing: span and trace. A span represents a single operation in a trace. A span can represent an HTTP request, a remote procedure call (RPC), a database query, or even the path that your code takes. A trace is a tree of spans showing the path of work through a system. You can distinguish a trace on its own by a unique 16-byte sequence called a TraceID. For more information on these concepts and how they relate to OpenTelemetry, see the OpenTelemetry documentation.
Tracing with Azure Monitor OpenTelemetry Distro
Azure Monitor OpenTelemetry Distro supports tracing for Azure SDKs by default. Just install and configure the distro and use Azure clients as usual.
# Enable Azure Monitor OpenTelemetry Distro
# It confiures Azure SDKs to use OpenTelemetry as well
from azure.monitor.opentelemetry import configure_azure_monitor
from opentelemetry import trace
configure_azure_monitor(
connection_string="<your-connection-string>"
)
# Use Azure SDKs as usual, here as an example with Storage SDKs
# you may also report your own spans for it.
from azure.storage.blob import BlobServiceClient
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span(name="MyApplication"):
client = BlobServiceClient.from_connection_string('connectionstring')
client.create_container('my_container') # Call will be traced
The Azure Monitor OpenTelemetry Distro can be found in the azure-monitor-opentelemetry package.
Tracing with generic OpenTelemetry
Check out your observability provider documentation on how to enable distributed tracing with OpenTelemetry or follow OpenTelemetry Python documentation on generic configuration.
In addition to common OpenTelemetry configuration, follow this steps to configure Azure SDKs:
-
Install the Azure Core OpenTelemetry Tracing plugin for Python with pip:
pip install azure-core-tracing-opentelemetry