Skip to main content

dagger-pytest-otel

A pytest plugin for OpenTelemetry instrumentation with Dagger.

This plugin automatically instruments pytest tests with OpenTelemetry spans, enabling test visibility in Dagger's TUI and Dagger Cloud.

Features

  • Zero configuration: Automatically creates spans for each test
  • TRACEPARENT propagation: Inherits trace context from Dagger
  • Session spans: Creates a parent span for the entire test session
  • Test hierarchy: Captures module, class, and function information
  • Outcome tracking: Records test pass/fail/skip status
  • Log capture: Forwards Python logs to OpenTelemetry
  • Exception recording: Records test exceptions on spans

Installation

pip install dagger-pytest-otel

Usage

Once installed, the plugin is automatically enabled. No code changes are required in your tests.

With Dagger

When running tests through Dagger, the TRACEPARENT environment variable is automatically set, and test spans will appear in the Dagger TUI and Dagger Cloud.

The pytest module bundles this plugin. A module that builds its own test container installs it:

# In your Dagger module
@function
async def test(self, source: dagger.Directory) -> str:
    return await (
        dag.container()
        .from_("python:3.11-slim")
        .with_directory("/src", source)
        .with_workdir("/src")
        .with_exec(["pip", "install", "pytest", "dagger-pytest-otel"])
        .with_exec(["pytest", "-v"])
        .stdout()
    )

Standalone

You can also use the plugin standalone with any OTLP-compatible backend:

export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
export TRACEPARENT="00-abc123...-def456...-01"  # Optional parent trace
pytest

Disabling

To disable instrumentation:

pytest --no-otel

Span Attributes

Each test span includes the following attributes:

Attribute Description
dagger.io/ui.boundary Prevents log bubbling in Dagger TUI
test.case.name Fully qualified pytest test case name
test.case.result.status Test result (pass/fail/skipped)
test.suite.name Pytest suite containing the test case

Session spans also include test.suite.run.status.

Test output

Captured stdout and stderr output is exported as OpenTelemetry logs on the active test span using Dagger's stdio.stream attribute. Python logging records are also forwarded as OpenTelemetry logs and mapped to stdout or stderr by severity.

Development

cd pytest/dagger_pytest_otel
uv run pytest

License

Apache-2.0

Metadata

Release files for dagger-pytest-otel 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dagger-pytest-otel 0.3.0
File Size Uploaded Provenance
dagger_pytest_otel-0.3.0.tar.gz 22.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dagger-pytest-otel 0.3.0
File Interpreter ABI Platform
dagger_pytest_otel-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.6 kB

Release files / dagger_pytest_otel-0.3.0.tar.gz

Download URL dagger_pytest_otel-0.3.0.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c958915415cfe9781b06ff49fbe61b9e9f11e79547e97f72dc1057f83eca8c14
BLAKE2b-256 checksum
How to use checksums
2138a67ada85423f5b6c53e4bf9b34461788d80ad53ba7b4805e79928a6a0b72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dagger_pytest_otel-0.3.0-py3-none-any.whl

Download URL dagger_pytest_otel-0.3.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db5448f3d70f337d66f5156c4b258e8f0f795b33aeb6e1a77f78535573c955e9
BLAKE2b-256 checksum
How to use checksums
b287723c403636db6f20e1d4564a65b389aa5b436779656d9ddf4ddee4d6ee76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.9 {"installer":{"name":"uv","version":"0.12.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for dagger-pytest-otel 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page