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:
- Azure Monitor OpenTelemetry exporters
- A subset of OpenTelemetry instrumentations that are officially supported as listed below.
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.
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:
- Azure subscription - Create a free account
- Azure Monitor - How to use application insights
- Opentelemetry SDK - Opentelemetry SDK for Python
- Python 3.7 or later - Install Python
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 |
exclude_instrumentations |
By default, all supported instrumentations are enabled to collect telemetry. Specify instrumentations you do not want to enable to collect telemetry by passing in a comma separated list of instrumented library names. e.g. ["requests", "flask"] |
|
resource |
Specifies the OpenTelemetry resource associated with your application. See this for default behavior. | OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES |
disable_logging |
If set to True , disables collection and export of logging telemetry. Defaults to False . |
|
disable_metrics |
If set to True , disables collection and export of metric telemetry. Defaults to False . |
|
disable_tracing |
If set to True , disables collection and export of distributed tracing telemetry. Defaults to False . |
|
logging_level |
Specifies the logging level of the logs you would like to collect for your logging pipeline. Defaults to 0 which is logging.NOTSET . |
|
logger_name |
Specifies the logger name under which logging will be instrumented. Defaults to "" which corresponds to the root logger. | |
logging_export_interval_ms |
Specifies the logging export interval in milliseconds. Defaults to 5000. | OTEL_BLRP_SCHEDULE_DELAY |
metric_readers |
Specifies the metric readers that you would like to use for your metric pipeline. Accepts a list of metric readers. | |
views |
Specifies the list of views to configure for the metric pipeline. See here for example usage. | |
sampling_ratio |
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_TRACES_SAMPLER_ARG |
tracing_export_interval_ms |
Specifies the distributed tracing export interval in milliseconds. Defaults to 5000. | OTEL_BSP_SCHEDULE_DELAY |
instrumentation_config |
Specifies a dictionary of kwargs that will be applied to instrumentation configuration. You can specify which instrumentation you want to configure by name in the key field and value as a dictionary representing kwargs for the corresponding instrumentation. Refer to the Supported Library section above for the list of supported library names. |
Example for use of instrumentation_config
:
...
configure_azure_monitor(
connection_string="<your-connection-string>",
instrumentation_config={
"flask": {
"excluded_urls": "http://localhost:8080/ignore",
},
"requests": {
"excluded_urls": "http://example.com"
}
}
)
...
Take a look at the specific instrumenation documentation for available configurations.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file azure-monitor-opentelemetry-1.0.0b11.tar.gz
.
File metadata
- Download URL: azure-monitor-opentelemetry-1.0.0b11.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e11cb4957c7928f885ed8a2f17a6d49d861c867bec3aa72311037d331dc70f52 |
|
MD5 | 3b4c7f9d4a26c4c2e10468c884292c68 |
|
BLAKE2b-256 | 92e244ae7b0148bb13a239ab2c615905751c84d4b2dda941660e449cfc77040c |
File details
Details for the file azure_monitor_opentelemetry-1.0.0b11-py2.py3-none-any.whl
.
File metadata
- Download URL: azure_monitor_opentelemetry-1.0.0b11-py2.py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b6e578706d19af6209917dbd7c0d48f171b33bbe1a649be555e0b2d2ef3e1f4 |
|
MD5 | ab8eb28de332af8d6a2575da7ee609aa |
|
BLAKE2b-256 | f25af30bd7e9795467141ba252c9f1c9596fe9b9a6f352d436f37a15e9a5bb41 |