Microsoft Azure Monitor Opentelemetry Exporter Python Samples

These code samples show common champion scenario operations with the AzureMonitorTraceExporter.

Installation

$ pip install azure-monitor-opentelemetry-exporter --pre

Run the Applications

Trace

  • Update APPLICATIONINSIGHTS_CONNECTION_STRING environment variable

  • Run the sample

$ # from this directory
$ python sample_trace.py

Client

  • Update APPLICATIONINSIGHTS_CONNECTION_STRING environment variable

  • Run the sample

$ pip install opentelemetry-instrumentation-requests
$ # from this directory
$ python sample_request.py

Server

  • Update APPLICATIONINSIGHTS_CONNECTION_STRING environment variable

  • Run the sample

$ pip install opentelemetry-instrumentation-requests
$ pip install opentelemetry-instrumentation-flask
$ # from this directory
$ python sample_server.py
  • Open http://localhost:8080/

Azure Service Bus Send

The following sample assumes that you have setup an Azure Service Bus namespace.

  • Update APPLICATIONINSIGHTS_CONNECTION_STRING environment variable

  • Update SERVICE_BUS_CONN_STR environment variable

  • Update SERVICE_BUS_QUEUE_NAME environment variable

  • Run the sample

$ # azure-servicebus library
$ pip install azure-servicebus
$ # azure sdk core tracing library for opentelemetry
$ pip install azure-core-tracing-opentelemetry
$ # from this directory
$ python sample_servicebus_send.py

Azure Service Bus Receive

The following sample assumes that you have setup an Azure Service Bus namespace.

  • Update APPLICATIONINSIGHTS_CONNECTION_STRING environment variable

  • Update SERVICE_BUS_CONN_STR environment variable

  • Update SERVICE_BUS_QUEUE_NAME environment variable

  • Run the sample

$ # azure-servicebus library
$ pip install azure-servicebus
$ # azure sdk core tracing library for opentelemetry
$ pip install azure-core-tracing-opentelemetry
$ # from this directory
$ python sample_servicebus_receive.py

Azure Storage Blob Create Container

The following sample assumes that you have setup an Azure Service Bus namespace.

  • Update APPLICATIONINSIGHTS_CONNECTION_STRING environment variable

  • Update AZURE_STORAGE_CONNECTION_STRING environment variable

  • Update AZURE_STORAGE_BLOB_CONTAINER_NAME environment variable

  • Run the sample

$ # azure-storage-blob library
$ pip install azure-storage-blob
$ # azure sdk core tracing library for opentelemetry
$ pip install azure-core-tracing-opentelemetry
$ # from this directory
$ python sample_storage.py

Explore the data

After running the applications, data would be available in Azure