Microsoft Azure Azure Core OpenTelemetry plugin Library for Python
Project description
Azure Core Tracing OpenTelemetry client library for Python
Getting started
Install the opentelemetry python for Python with pip:
pip install azure-core-tracing-opentelemetry
Now you can use opentelemetry for Python as usual with any SDKs that are compatible with azure-core tracing. This includes (not exhaustive list), azure-storage-blob, azure-keyvault-secrets, azure-eventhub, etc.
Key concepts
-
You don't need to pass any context, SDK will get it for you
-
Those lines are the only ones you need to enable tracing
from azure.core.settings import settings from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan settings.tracing_implementation = OpenTelemetrySpan
Examples
There is no explicit context to pass, you just create your usual opentelemetry tracer and call any SDK code that is compatible with azure-core tracing. This is an example using Azure Monitor exporter, but you can use any exporter (Zipkin, etc.).
# Declare OpenTelemetry as enabled tracing plugin for Azure SDKs
from azure.core.settings import settings
from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
settings.tracing_implementation = OpenTelemetrySpan
# Example of Azure Monitor exporter, but you can use anything OpenTelemetry supports
from azure_monitor import AzureMonitorSpanExporter
exporter = AzureMonitorSpanExporter(
instrumentation_key="uuid of the instrumentation key (see your Azure Monitor account)"
)
# Regular open telemetry usage from here, see https://github.com/open-telemetry/opentelemetry-python
# for details
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
from opentelemetry.sdk.trace.export import SimpleExportSpanProcessor
# Simple console exporter
exporter = ConsoleSpanExporter()
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(exporter)
)
# Example with Storage SDKs
from azure.storage.blob import BlobServiceClient
with tracer.start_as_current_span(name="MyApplication"):
client = BlobServiceClient.from_connection_string('connectionstring')
client.create_container('mycontainer') # Call will be traced
Azure Exporter can be found in the package opentelemetry-azure-monitor-exporter
Troubleshooting
This client raises exceptions defined in Azure Core.
Next steps
More documentation on OpenTelemetry configuration can be found on the OpenTelemetry website
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Release History
1.0.0b4 (2020-05-04)
link
andlink_from_headers
now accepts attributes.
1.0.0b3 (2020-04-06)
Features
- Pinned opentelemetry-api to version 0.6b0
1.0.0b2 (2020-03-09)
Features
- Pinned opentelemetry-api to version 0.4a0
1.0.0b1
Features
- Opentelemetry implementation of azure-core tracing protocol
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-core-tracing-opentelemetry-1.0.0b4.zip
.
File metadata
- Download URL: azure-core-tracing-opentelemetry-1.0.0b4.zip
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad1e9e545b887c46283c3a9fd3f4ea171eb285a1bc41b1e70a44a43385cf54d9 |
|
MD5 | b8a21b33738874920aa6d993d89c6b50 |
|
BLAKE2b-256 | e6621961f178b65fe9324de5a2c178e196966922c204297c21d2f354c442bfeb |
File details
Details for the file azure_core_tracing_opentelemetry-1.0.0b4-py2.py3-none-any.whl
.
File metadata
- Download URL: azure_core_tracing_opentelemetry-1.0.0b4-py2.py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d6aff8a77aba5614ca7e2e8419614df29584e4afa8f2bf56b0bb1f5f8cf1d55 |
|
MD5 | 0843ff1e00bed793a17598a322b8f278 |
|
BLAKE2b-256 | 73e7c34f4bf017cc9f0c5beaba1eb89dd241bd6b5cf717262f36860ab72b4104 |