OpenTelemetry plugin for Pytest
Project description
pytest_otel
Features
pytest-otel plugin for reporting OpenTelemetry spans of tests executed.
Requirements
- opentelemetry-api
- opentelemetry-exporter-otlp
- opentelemetry-sdk
- pytest
Installation
You can install "pytest-otel" via pip or using the setup.py script.
pip install pytest-otel
Usage
pytest_otel is configured by adding some parameters to the pytest command line. Below are the descriptions:
- --otel-endpoint: URL for the OpenTelemetry server. (Required). Env variable:
OTEL_EXPORTER_OTLP_ENDPOINT - --otel-headers: Additional headers to send (i.e.: key1=value1,key2=value2). Env variable:
OTEL_EXPORTER_OTLP_HEADERS - --otel-service-name: Name of the service. Env variable:
OTEL_SERVICE_NAME - --otel-session-name: Name for the main span.
- --otel-traceparent: Trace parent ID. Env variable:
TRACEPARENT. See https://www.w3.org/TR/trace-context-1/#trace-context-http-headers-format - --otel-insecure: Disables TLS. Env variable:
OTEL_EXPORTER_OTLP_INSECURE
pytest --otel-endpoint https://otelcollector.example.com:4317 \
--otel-headers "authorization=Bearer ASWDCcCRFfr" \
--otel-service-name pytest_otel \
--otel-session-name='My_Test_cases' \
--otel-traceparent=00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 \
--otel-insecure=False
IMPORTANT: If you use --otel-headers the transaction metadata might expose those arguments
with their values. In order to avoid any credentials to be exposed, it's recommended to use the environment variables.
For instance, given the above example, a similar one with environment variables can be seen below:
OTEL_EXPORTER_OTLP_ENDPOINT=https://apm.example.com:8200 \
OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer ASWDCcCRFfr" \
OTEL_SERVICE_NAME=pytest_otel \
TRACEPARENT=00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 \
OTEL_EXPORTER_OTLP_INSECURE=False \
pytest --otel-session-name='My_Test_cases'
Demos
License
Distributed under the terms of the Apache License Version 2.0_ license, "pytest-otel" is free and open source software
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_otel-1.7.1.tar.gz.
File metadata
- Download URL: pytest_otel-1.7.1.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4faf19715d495c8029200aead139ca0259f6ee9d2a53f9e6f539aec6d1caf278
|
|
| MD5 |
4a90169404c0961bd634e18957bae033
|
|
| BLAKE2b-256 |
b365671bd6737a4aa04f77c36e938159ad91de76b15d3bdff39b7ba7687817cc
|
File details
Details for the file pytest_otel-1.7.1-py2.py3-none-any.whl.
File metadata
- Download URL: pytest_otel-1.7.1-py2.py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad8b9dd9bd5b1aaea4cfe57329187b8d9a15a0c514e679579793bbbdf13571f9
|
|
| MD5 |
7590c875790cd2f3560c907d4a0e8b6e
|
|
| BLAKE2b-256 |
6f3929af858da62f51c1a5b78e5dd4517c0949803ef9c6c66c55e18f95c65a73
|