Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.1.0rc1

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.1.0rc1
File Size Uploaded Provenance
dagger_pytest_otel-0.1.0rc1.tar.gz 22.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 40.7 kB

Release files / dagger_pytest_otel-0.1.0rc1.tar.gz

Download URL dagger_pytest_otel-0.1.0rc1.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea58bc1162598e2572d6ffd177da4f779ad2084768048768762ceb8a84fb83e5
BLAKE2b-256 checksum
How to use checksums
27096e9037ce417f55ab0f628089c364c45786985e8675e0e804708d8f3f5689
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.1.0rc1-py3-none-any.whl

Download URL dagger_pytest_otel-0.1.0rc1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e1475e1d5e92651244266198402da2212ec683b480f48d3cdcba3aa303543b3
BLAKE2b-256 checksum
How to use checksums
e5b7ff4116db06e4466f35725abcf4692145c5b7d98efaff1ad5cd8cab7f389d
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.1.0rc1

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