skillfed

pytest-otel

OpenTelemetry plugin for Pytest

pytest-otel v2.4.0 89.0K downloads/30d#13,685 on PyPI
Permissive license Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) Active released

What it is and what it does

pytest-otel is a pytest plugin that integrates OpenTelemetry tracing into your test runs. It wraps test execution in spans and exports them to an OTLP-compatible backend (such as Jaeger or Elastic APM), allowing you to observe test performance and behavior through your observability stack. The plugin is configured via command-line flags or environment variables and supports both gRPC and HTTP/protobuf OTLP protocols.

You provide an OpenTelemetry endpoint URL, service name, and optional headers, then run pytest with the plugin enabled. Each test becomes a span in your trace backend, where you can inspect execution time, failures, and correlate test runs with other system traces. The plugin supports dotenv files for managing configuration and allows trace parent IDs to be passed in for linking to upstream traces.

Use it for:

  • Export test execution traces to Jaeger for visual debugging of slow or flaky tests.
  • Correlate test failures with application traces in Elastic Stack or other APM tools.
  • Monitor test suite performance over time by analyzing span data in your observability platform.
  • Link test execution spans to distributed traces from CI/CD pipelines or deployment systems.
  • Debug test interactions with external services by viewing spans alongside application instrumentation.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that captures and exports OpenTelemetry spans for each test execution, sending trace data to an OTLP-compatible backend.

Yes, if you already run an OpenTelemetry collector and want to observe test execution within your observability stack. The plugin is actively maintained, has low install friction, and is permissively licensed. Install only if you have an OTLP endpoint available and a clear use case for tracing test runs; it adds a runtime dependency on three OpenTelemetry packages and requires Python 3.10+.

Install

pytest-otel on PyPI

pip

pip install pytest-otel

uv

uv add pytest-otel

poetry

poetry add pytest-otel

Installing pytest-otel

Before you install

Low friction install with a pure-Python wheel. Actively maintained as of 46 days ago. Requires pytest and three OpenTelemetry packages (api, sdk, exporter-otlp) as runtime dependencies.

License in practice

Apache License 2.0 (permissive) allows free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.

Quickstart

pip install pytest-otel

pytest --otel-endpoint https://otelcollector.example.com:4317 \
       --otel-service-name my_service \
       --otel-session-name='My_Test_cases'

Requires an OpenTelemetry collector or backend endpoint (--otel-endpoint is mandatory); Python 3.10 or later.

Verify before relying

  • Whether the plugin automatically instruments all test functions or requires explicit decorator/fixture usage.
  • Support for distributed tracing context propagation across test suites or CI/CD pipelines.
  • Performance overhead of span export during test execution.

Package facts

License Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 4 — opentelemetry-api, opentelemetry-exporter-otlp, opentelemetry-sdk, pytest
Maintenance actively maintained — 46 days since the last release
First released
Downloads 89,003/month — #13,685 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_otel-2.4.0-py2.py3-none-any.whl

Keywords: pytest, otel, opentelemetry, debug

Environment :: PluginsFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: LibrariesTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest opentelemetry tracingtest span export otlppytest observability plugintest execution tracingopentelemetry pytest integration
observabilitydistributed-tracingtesting

More Libraries packages

urllib3

urllib3 is an HTTP client library that provides…

permissive · top 100 on PyPI

requests

Requests is a Python HTTP library that…

permissive · top 100 on PyPI

pluggy

Pluggy provides a plugin system that lets you…

permissive · top 100 on PyPI

python-dateutil

Provides parsing, arithmetic, and recurrence…

permissive · top 100 on PyPI

six

Six provides utility functions to write Python…

permissive · top 100 on PyPI

pytest

pytest is a testing framework that lets you…

permissive · top 100 on PyPI

otel-ci

Records and exports OpenTelemetry spans from…

unclear · top 15,000 on PyPI

pytest-opentelemetry

A pytest plugin that instruments test runs with…

permissive · top 5,000 on PyPI

otel-extensions

Provides helper classes, decorators, and…

permissive · top 15,000 on PyPI

opentelemetry-exporter-otlp-proto-grpc

Exports telemetry data from Python applications…

permissive · top 1,000 on PyPI

opentelemetry-exporter-otlp

Installs OpenTelemetry exporters for sending…

permissive · top 1,000 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

microsoft-opentelemetry

Provides a unified OpenTelemetry distribution…

permissive · top 15,000 on PyPI

pyroscope-otel

Connects OpenTelemetry tracing with Pyroscope…

permissive · top 5,000 on PyPI

opentelemetry-test-utils

Provides test utilities and helpers for writing…

permissive · top 15,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI