Skip to main content

pytest-otel report OpenTelemetry traces about test executed

Project description

Features

pytest-otel plugin for reporting APM traces of tests executed.

OpenTelemetry

Requirements

  • opentelemetry-api == 1.5.0
  • opentelemetry-exporter-otlp == 1.5.0
  • opentelemetry-sdk == 1.5.0

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_otel-1.0.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_otel-1.0.2-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest_otel-1.0.2.tar.gz.

File metadata

  • Download URL: pytest_otel-1.0.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pytest_otel-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4e47066cf0686b72681e5c0e5b83e9c42c5b0f634d538e047ed1b3f506c24c59
MD5 b8a7b98011c08383e112992044c1132e
BLAKE2b-256 e8ce30f9d75a261fe73a8b6c26ac9f67f5cbd6fa55a7a6849840c362ecd7b3ed

See more details on using hashes here.

File details

Details for the file pytest_otel-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_otel-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pytest_otel-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 816c2f974ce25a5fb16e5ce85f30f743e6eba4e57dc3e217b5c4a19f17d6f2f4
MD5 30027a265264c7324a1c1d7c3aa86336
BLAKE2b-256 d96b1394b7f5de982d9495858ada9ac08a7d6702605f7b9a5b72bcea53db8357

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page