-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Telemetry with Azure SDKs
All the Azure SDKs support distributed tracing, metric collection, and logging using the OpenCensus library. Through the use of Azure Monitor exporter, you will be able to send this collected telemetry to Application Insights.
More info on this can be found here.
Now you can use OpenCensus for Python as usual with any SDKs that is compatible with azure-core tracing.
Moreover, this can be done without the need to pass any context.
The following sample shows using tracing with Azure Monitor exporter.
from opencensus.ext.azure.trace_exporter import AzureExporter
from opencensus.trace.tracer import Tracer
from opencensus.trace.samplers import AlwaysOnSampler
from azure.storage.blob import BlobServiceClient
exporter = AzureExporter(
instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)"
)
tracer = Tracer(exporter=exporter, sampler=AlwaysOnSampler())
with tracer.span(name="MyApplication") as span:
client = BlobServiceClient.from_connection_string('connectionstring')
client.delete_container('mycontainer') # Call will be traced
A detailed explanation with a sample for logging can be found on https://docs.microsoft.com/azure/azure-monitor/app/opencensus-python#logs
A detailed sample with explanation for collecting metrics can be found on https://docs.microsoft.com/azure/azure-monitor/app/opencensus-python#metrics