Elastic Distribution for OpenTelemetry Python
Project description
elastic-opentelemetry -- Elastic Distribution for OpenTelemetry Python
elastic-opentelemetry
is the Elastic Distribution for OpenTelemetry Python.
Installation
pip install elastic-opentelemetry
Usage
Our distribution does not install any instrumentation package by default, instead it relies on the
opentelemetry-bootstrap
command to scan the installed packages and install the available instrumentation.
The following command will install all the instrumentations available for libraries found installed
in your environment:
opentelemetry-bootstrap --action=install
It will be useful to add this command every time you need to deploy an updated version of your application, e.g. into your container image build process.
At runtime you have to make some environment variables available to provide the needed configuration. A service name is required to have your app easily recognizable from the other. Then you need to provide the authorization headers for authentication with Elastic cloud and the project endpoint where to send your data. For details about the authentication format see the chapter below.
OTEL_RESOURCE_ATTRIBUTES=service.name=<app-name>
OTEL_EXPORTER_OTLP_HEADERS="Authorization=<url encoded apikey header value>"
OTEL_EXPORTER_OTLP_ENDPOINT=<your elastic cloud url>
We are done with the configuration and the last piece of the puzzle is wrapping your service invocation with
opentelemetry-instrument
that is the wrapper that provides automatic instrumentation:
opentelemetry-instrument <command to start your service>
For a web service running with gunicorn it may looks like:
opentelemetry-instrument gunicorn main:app
Authentication
Authentication is done passing an URL encoded API Key as Authorization
header, given the Api Key available
from your project dashboard you can encode it this way:
from urllib.parse import quote
quote("ApiKey <your api key>)
In the end it will look something like the following:
"ApiKey%20RM2sVN55Su49RgCYNI7SvYoeyWCyt3sbdFirjvmtin6IavUfZrBXCInwao%3D%3D"
Configuration
The distribution supports all the configuration variables from OpenTelemetry Python project version 1.25.0.
Default configuration variables
This distribution sets the following defaults:
OTEL_TRACES_EXPORTER
:otlp
OTEL_METRICS_EXPORTER
:otlp
OTEL_EXPORTER_OTLP_PROTOCOL
:grpc
OTEL_EXPERIMENTAL_RESOURCE_DETECTORS
:process_runtime,otel,telemetry_distro
Distribution specific configuration variables
ELASTIC_OTEL_SYSTEM_METRICS_ENABLED
(default:false
): when sets totrue
sends system namespace metrics.
License
This software is licensed under the Apache License, version 2 ("Apache-2.0").
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
Built Distribution
File details
Details for the file elastic_opentelemetry-0.1.0.tar.gz
.
File metadata
- Download URL: elastic_opentelemetry-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57ac764035460e97d3e90807d374fe18586aefd17949ce8ea2889d2e501e1237 |
|
MD5 | 0ae02bb21895eb6e2f008522533de53b |
|
BLAKE2b-256 | 7270c58ee1ee92d57306299e4d477f65039e535aedf4d8298db0c135249a1caa |
File details
Details for the file elastic_opentelemetry-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: elastic_opentelemetry-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b0480b770e586a564dd86cf3b0d4f59fdd587bf0580c0841042a8f3abd7a688 |
|
MD5 | cfa6c5034157878e948b9bb3b586dc52 |
|
BLAKE2b-256 | 30d1a29ca884547b452b78d2d407982558b8da5e13281e22b8a34faf79393184 |