зеркало из
1
0
Форкнуть 0
3 Telemetry with Azure SDKs
Rakshith Bhyravabhotla редактировал(а) эту страницу 2021-08-02 10:29:32 -07:00

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.

OpenCensus integration with azure-core

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

Logging

A detailed explanation with a sample for logging can be found on https://docs.microsoft.com/azure/azure-monitor/app/opencensus-python#logs

Metrics

A detailed sample with explanation for collecting metrics can be found on https://docs.microsoft.com/azure/azure-monitor/app/opencensus-python#metrics