{"id":45919,"library":"pytest-otel","title":"pytest-otel","description":"OpenTelemetry plugin for Pytest that automatically traces test execution, fixtures, and assertions. Currently at version 2.2.1, with monthly releases following OpenTelemetry SDK updates.","status":"active","version":"2.2.1","language":"python","source_language":"en","source_url":"https://github.com/labd/pytest-otel","tags":["pytest","opentelemetry","testing","tracing"],"install":[{"cmd":"pip install pytest-otel","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"pytest-otel is a plugin, not a package with public API. Just import the package to register hooks.","wrong":"from pytest_otel import otel","symbol":"pytest_otel","correct":"import pytest_otel"}],"quickstart":{"code":"# conftest.py\nimport os\nimport pytest_otel\n\n# The plugin activates automatically. To configure:\n# export OTEL_SERVICE_NAME=my-test-service\n# export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317\n\ndef test_example():\n    assert 1 + 1 == 2","lang":"python","description":"After installing, the plugin hooks into pytest automatically. Set OpenTelemetry environment variables to configure exporters and service name."},"warnings":[{"fix":"Upgrade to 2.2.1, remove any monkey-patching of internal methods, and ensure your OpenTelemetry SDK is >=1.20.","message":"In v2.0.0, the plugin dropped support for Python 3.8 and refactored the hook internals. Custom spans from older versions may not work without migration.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Replace `--otel-exporter` with `export OTEL_EXPORTER_OTLP_ENDPOINT=<endpoint>`.","message":"The `--otel-exporter` CLI option was deprecated in 2.1.0 and will be removed. Use environment variable OTEL_EXPORTER_OTLP_ENDPOINT instead.","severity":"deprecated","affected_versions":">=2.1.0"},{"fix":"Manually instrument subprocesses using OpenTelemetry's propagator context extraction.","message":"The plugin does not trace subprocess calls by default. If your tests spawn subprocesses, they will not appear in traces.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'2.2.1':19 'assert':15 'automat':9 'current':16 'execut':12 'fixtur':13 'follow':23 'month':21 'opentelemetri':4,24,28 'otel':3 'plugin':5 'pytest':2,7,27 'pytest-otel':1 'releas':22 'sdk':25 'test':11,29 'trace':10,30 'updat':26 'version':18","created_at":"2026-06-07T12:57:22.988228+00:00","updated_at":"2026-06-07T12:57:22.988228+00:00","problems":[{"fix":"Install the OTLP exporter: `pip install opentelemetry-exporter-otlp`.","cause":"Missing OpenTelemetry SDK dependency when not using pip extra.","error":"ModuleNotFoundError: No module named 'opentelemetry'"},{"fix":"Do not call the plugin's internal methods. Rely on environment configuration only.","cause":"Trying to call `pytest_otel.get_tracer()` before plugin initialization.","error":"TypeError: 'NoneType' object is not callable"},{"fix":"Set the OTEL_TRACES_EXPORTER environment variable to a valid exporter, e.g., `export OTEL_TRACES_EXPORTER=otlp`.","cause":"No OpenTelemetry tracer provider configured. The plugin issues this warning.","error":"TracerProvider not set, defaulting to noop tracer"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}