A pytest plugin for instrumenting test runs via OpenTelemetry
Project description
pytest-opentelemetry
Instruments your pytest runs, exporting the spans and timing via OpenTelemetry.
Installation and Usage
pip install pytest-opentelemetry
Installing a library that exposes a specific pytest-related entry point is automatically loaded as a pytest plugin. Simply installing the plugin should be enough to register it for pytest.
Using the --export-traces
flag enables trace exporting (otherwise, the created spans
will only be tracked in memory):
pytest --export-traces
By default, this exports traces to http://localhost:4317
, which will work well if
you're running a local OpenTelemetry
Collector exposing the OTLP gRPC interface.
You can use any of the OpenTelemetry environment
variables
to adjust the tracing export or behavior:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://another.collector:4317
pytest --export-traces
Only the OTLP over gRPC exporter is currently supported.
Visualizing Test Traces
One quick way to visualize test traces would be to use an OpenTelemetry Collector feeding traces to Jaeger. This can be configured with a minimal Docker Compose file like:
version: "3.8"
services:
jaeger:
image: jaegertracing/all-in-one:1.33
ports:
- 16686:16686 # frontend
- 14250:14250 # model.proto
collector:
image: otel/opentelemetry-collector-contrib:0.49.0
depends_on:
- jaeger
ports:
- 4317:4317 # OTLP (gRPC)
volumes:
- ./otelcol-config.yaml:/etc/otelcol-contrib/config.yaml:ro
With this otelcol-config.yaml
:
receivers:
otlp:
protocols:
grpc:
processors:
batch:
exporters:
jaeger:
endpoint: jaeger:14250
tls:
insecure: true
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [jaeger]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest-opentelemetry-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c302a90d9ec515ef46f82c8ccccc92de0d15125bb25a5fe75cb99a3d52a7d70d |
|
MD5 | 8ee16bc460ce925371b4c605ba516500 |
|
BLAKE2b-256 | 1d94f673d2a9d995eb2815525369bb709a6b5b595ef047d79dd220dc5bed2af4 |
Hashes for pytest_opentelemetry-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c97bded7a1efadc81464aa7d4cd992fdb5fd30b0f048427a981ce897b4a825d |
|
MD5 | 0acc6b3dbd9349456e490e493df21813 |
|
BLAKE2b-256 | bd9e8a70e2859c672fd6aac94f0861d0a2d6bad2ddcf401dd29c77e7b41f1adf |