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
- OpenTelemetry Requests Instrumentation
- OpenTelemetry Django Instrumentation
- OpenTelemetry Flask Instrumentation
- OpenTelemetry Psycopg2 Instrumentation
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:
- 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. - instrumentations - Specifies the libraries with instrumentations that you would like to use. Accepts a comma separated list. e.g.
["requests", "flask"]
- disable_logging - If set to
True
, disables collection and export of logging telemetry. Defaults toFalse
. - disable_metrics - If set to
True
, disables collection and export of metric telemetry. Defaults toFalse
. - disable_tracing - If set to
True
, disables collection and export of distributed tracing telemetry. Defaults toFalse
. - resource - Specified the OpenTelemetry resource associated with your application. See this for default behavior.
- logging_level - Specifies the logging level of the logs you would like to collect for your logging pipeline. Defaults to 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_millis - Specifies the logging export interval in milliseconds. Defaults to 5000.
- 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.
- tracing_export_interval_millis - Specifies the distributed tracing export interval in milliseconds. Defaults to 5000.
Exporter configurations
You can pass 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,
)
...
Instrumentation configurations
You can pass in instrumentation specific configuration into configure_azure_monitor
with the key <instrumented-library-name>_config
and value as a dictionary representing kwargs
for the corresponding instrumentation. Note the instrumented library must also be enabled through the instrumentations
configuration.
...
configure_azure_monitor(
connection_string="<your-connection-string>",
instrumentations=["flask", "requests"],
flask_config={"excluded_urls": "http://localhost:8080/ignore"},
requests_config={"excluded_urls": "http://example.com"},
)
...
Take a look at the specific instrumenation documentation for available configurations.
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.0b9.tar.gz
.
File metadata
- Download URL: azure-monitor-opentelemetry-1.0.0b9.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9536d86da42b35c413181dfabb3c41a3545aae43024fe6fd8414a7ea26d18177 |
|
MD5 | 817da6b8351605fdf9affd10b01b7e69 |
|
BLAKE2b-256 | c10bcbd2b660d5bf2ced406a4e5913fac5e068f7940577041df1d851b8dcdf59 |
File details
Details for the file azure_monitor_opentelemetry-1.0.0b9-py2.py3-none-any.whl
.
File metadata
- Download URL: azure_monitor_opentelemetry-1.0.0b9-py2.py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f87438a03b72f770d6bad7c59c7445de6bcaf0e55718c12524feadcc555f3e46 |
|
MD5 | ae031e32d56621087bbea7fc50cd9ecb |
|
BLAKE2b-256 | cc38ce6ed25fc669763e90002cb42bd56a88cbb89f17959e7e947aaf623359a2 |