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

Built distribution (wheel)

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

Total release size: 40.7 kB

Release files / dagger_pytest_otel-0.3.0rc1.tar.gz

Download URL dagger_pytest_otel-0.3.0rc1.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5592bc7567d1bdf85efb12e5eff64f5f76d8c1bbc53444edbee808dfea7c8095
BLAKE2b-256 checksum
How to use checksums
31f243b85f3039ec056773dd0ad94b3041bddc56ae0ea8e0ea8928ac77e2e120
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.0rc1-py3-none-any.whl

Download URL dagger_pytest_otel-0.3.0rc1-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af7d7c4647672c0b0040183512bdfd6da4e80a2d0f34b7f3c816d61eb4952406
BLAKE2b-256 checksum
How to use checksums
87fa89c900b728ebdcbf17332bf0cb88cbbb7415ed1e93783ce5d3b3dc649cf2
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.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