Skip to main content

Microsoft Azure Monitor Opentelemetry Distro Client Library for Python

Project description

Azure Monitor Opentelemetry Distro

The Azure Monitor Distro of Opentelemetry Python provides multiple installable components available for an Opentelemetry Azure Monitor monitoring solution. It allows you to instrument your Python applications to capture and report telemetry to Azure Monitor via the Azure monitor exporters.

This distro automatically installs the following libraries:

Officially supported instrumentations

OpenTelemetry instrumentations allow automatic collection of requests sent from underlying instrumented libraries. The following is a list of OpenTelemetry instrumentations that come bundled in with the Azure monitor distro. If you would like to add support for another OpenTelemetry instrumentation, please submit a feature request. In the meantime, you can use the OpenTelemetry instrumentation manually via it's own APIs (i.e. instrument()) in your code. See this for an example.

Instrumentation Supported library Supported versions
OpenTelemetry Django Instrumentation django link
OpenTelemetry FastApi Instrumentation fastapi link
OpenTelemetry Flask Instrumentation flask link
OpenTelemetry Psycopg2 Instrumentation psycopg2 link
OpenTelemetry Requests Instrumentation requests link
OpenTelemetry UrlLib Instrumentation urllib All
OpenTelemetry UrlLib3 Instrumentation urllib3 link

Azure Core Distributed Tracing

Using the Azure Core Tracing OpenTelemetry library, you can automatically capture the distributed tracing from Azure Core libraries. See the associated sample for more information. This feature is enabled automatically.

Getting started

Key Concepts

This package bundles a series of OpenTelemetry and Azure Monitor components to enable the collection and sending of telemetry to Azure Monitor. For MANUAL instrumentation, use the configure_azure_monitor function. AUTOMATIC instrumentation is not yet supported.

The Azure Monitor OpenTelemetry exporters are the main components in accomplishing this. You will be able to use the exporters and their APIs directly through this package. Please go the exporter documentation to understand how OpenTelemetry and Azure Monitor components work in enabling telemetry collection and exporting.

Currently, all instrumentations available in OpenTelemetry are in a beta state, meaning they are not stable and may have breaking changes in the future. Efforts are being made in pushing these to a more stable state.

Prerequisites

To use this package, you must have:

Install the package

Install the Azure Monitor Opentelemetry Distro with pip:

pip install azure-monitor-opentelemetry --pre

Usage

You can use configure_azure_monitor to set up instrumentation for your app to Azure Monitor. configure_azure_monitor supports the following optional arguments:

Parameter Description Environment Variable
connection_string The connection string for your Application Insights resource. The connection string will be automatically populated from the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable if not explicitly passed in. APPLICATIONINSIGHTS_CONNECTION_STRING

You can configure further with OpenTelemetry environment variables such as:

Environment Variable Description
OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES Specifies the OpenTelemetry resource associated with your application.
OTEL_LOGS_EXPORTER If set to None, disables collection and export of logging telemetry.
OTEL_METRICS_EXPORTER If set to None, disables collection and export of metric telemetry.
OTEL_TRACES_EXPORTER If set to None, disables collection and export of distributed tracing telemetry.
OTEL_BLRP_SCHEDULE_DELAY Specifies the logging export interval in milliseconds. Defaults to 5000.
OTEL_BSP_SCHEDULE_DELAY Specifies the distributed tracing export interval in milliseconds. Defaults to 5000.
OTEL_TRACES_SAMPLER_ARG Specifies the ratio of distributed tracing telemetry to be sampled. Accepted values are in the range [0,1]. Defaults to 1.0, meaning no telemetry is sampled out.
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS Specifies which of the supported instrumentations to disable. Disabled instrumentations will not be instrumented as part of configure_azure_monitor. However, they can still be manually instrumented by users after the fact. Accepts a comma-separated list of lowercase entry point names for instrumentations. For example, set to "psycopg2,fastapi" to disable the Psycopg2 and FastAPI instrumentations. Defaults to an empty list, enabling all supported instrumentations.

Azure monitor OpenTelemetry Exporter configurations

You can pass Azure monitor OpenTelemetry exporter configuration parameters directly into configure_azure_monitor. See additional configuration related to exporting here.

...
configure_azure_monitor(
   connection_string="<your-connection-string>",
   disable_offline_storage=True, 
)
...

Samples

Samples are available here to demonstrate how to utilize the above configuration options.

Additional documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure-monitor-opentelemetry-1.0.0b15.tar.gz (68.7 kB view details)

Uploaded Source

Built Distribution

azure_monitor_opentelemetry-1.0.0b15-py2.py3-none-any.whl (97.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file azure-monitor-opentelemetry-1.0.0b15.tar.gz.

File metadata

File hashes

Hashes for azure-monitor-opentelemetry-1.0.0b15.tar.gz
Algorithm Hash digest
SHA256 80939b6b8dd3232d529b988f038df6289e06683d2bda2347a6eeb3c9e0294556
MD5 ea65d5bc58cbaf36bceb0ab6658911dd
BLAKE2b-256 5f07d6894fa511fd2ed4c16aa10d93cdfa24b527cbf565db7811b55070489f04

See more details on using hashes here.

File details

Details for the file azure_monitor_opentelemetry-1.0.0b15-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for azure_monitor_opentelemetry-1.0.0b15-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a29e9321c0e11b7ee2694fac8af0e888d15cb1d61f2e072a3e4cd033d5ac5cd7
MD5 da627f13b893ac07463f38ed4e61f686
BLAKE2b-256 536de8878bf93717fb9ef1197198ec98ea99afa053351e9480fd1810fd0ea318

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page