pytest-opentelemetry
A pytest plugin for instrumenting test runs via OpenTelemetry
What it is and what it does
pytest-opentelemetry is a pytest plugin that automatically captures detailed timing and execution data from your test runs as OpenTelemetry spans, then exports them to a tracing backend. It integrates seamlessly with pytest as a plugin—just install it and use the --export-traces flag to start collecting traces. By default it sends data to http://localhost:4317 (an OpenTelemetry Collector), which you can redirect to visualization tools like Jaeger.
The plugin helps identify test bottlenecks and performance regressions by giving you a detailed timeline of what your tests are doing. It works especially well with applications already instrumented with OpenTelemetry, letting you see the full stack from test code through database queries and network calls. It also supports pytest-xdist for distributed test runs, automatically unifying traces across multiple processes or hosts, and can nest test runs under a parent trace via the --trace-parent argument.
Use it for:
- Identify which tests or fixtures are slowest in a large test suite to prioritize optimization efforts.
- Visualize integration test execution against a staging environment using Jaeger to debug failures faster.
- Connect test traces to application traces when testing OpenTelemetry-instrumented services to see end-to-end behavior.
- Debug local test performance issues by running pytest-opentelemetry locally and inspecting traces in Jaeger.
- Track test suite runtime trends over time by exporting traces to a persistent backend for historical analysis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that instruments test runs with OpenTelemetry, exporting span and timing data to trace backends like Jaeger for performance analysis and debugging.
Yes, if you already use or plan to adopt OpenTelemetry for observability and want detailed visibility into test performance. The plugin is actively maintained, has no known vulnerabilities, and integrates cleanly with pytest. Install it if you need to profile test bottlenecks or correlate test execution with application traces; skip it if you have no observability infrastructure or don't need test-level tracing.
Install
pytest-opentelemetry on PyPI
pip
pip install pytest-opentelemetryuv
uv add pytest-opentelemetrypoetry
poetry add pytest-opentelemetryInstalling pytest-opentelemetry
Before you install
Low friction installation as a pure Python wheel. Actively maintained with a recent release (2025-04-25) and ongoing commits; last commit 2026-07-26. Depends on five runtime packages including opentelemetry-sdk and pytest itself, all standard in the ecosystem.
License in practice
MIT license (permissive) means you can use, modify, and distribute this plugin freely in commercial and private projects with minimal restrictions.
Quickstart
pip install pytest-opentelemetry
pytest --export-traces
# With custom collector endpoint:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4317
pytest --export-traces
Requires an OpenTelemetry Collector or compatible OTLP gRPC endpoint running (default http://localhost:4317); only OTLP over gRPC exporter is currently supported.
Verify before relying
- Whether pytest-xdist integration works with all versions of pytest-xdist or has known incompatibilities.
- Performance overhead of instrumentation on test suite runtime when traces are exported.
- Support for other OpenTelemetry exporters beyond OTLP gRPC in future versions.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — opentelemetry-api, opentelemetry-container-distro, opentelemetry-sdk, opentelemetry-semantic-conventions, pytest |
| Maintenance | actively maintained — 476 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,205,304/month — #4,225 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_opentelemetry-1.1.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
buildkite-test-collectorCollects test execution data from pytest and…
permissive · top 5,000 on PyPI
pytest-otelA pytest plugin that captures and exports…
permissive · top 15,000 on PyPI
opentelemetry-exporter-jaegerInstalls Jaeger exporters for OpenTelemetry to…
permissive · top 15,000 on PyPI
opentelemetry-exporter-jaeger-proto-grpcExports OpenTelemetry tracing data to Jaeger…
permissive · top 15,000 on PyPI
azure-monitor-opentelemetry-exporterExports OpenTelemetry traces, metrics, and logs…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opentelemetry-exporter-jaeger-thriftExports OpenTelemetry tracing data to Jaeger…
permissive · top 15,000 on PyPI
opentelemetry-test-utilsProvides test utilities and helpers for writing…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-jinja2Adds OpenTelemetry tracing instrumentation to…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-wsgiProvides WSGI middleware for OpenTelemetry that…
permissive · top 1,000 on PyPI