Skip to main content

metaflow-observability

CI PyPI License: Apache-2.0 Python 3.9+ Docs

Get production metrics for every Metaflow step — without changing your flow code.

The problem

When a Metaflow pipeline slows down or crashes in production, you have no time-series data to tell you whether it was CPU saturation, a memory spike, a disk bottleneck, or a GPU stall. You're left digging through logs after the fact. Metaflow's built-in tooling gives you per-run artifacts and cards, but nothing you can alert on or trend over time.

Quick start

pip install metaflow-observability
from metaflow import FlowSpec, step
from metaflow.decorators import observability

class MyFlow(FlowSpec):

    @observability
    @step
    def train(self):
        ...  # your code — metrics collected automatically
        self.next(self.end)

    @step
    def end(self):
        pass

if __name__ == "__main__":
    MyFlow()

Metrics are exported via OpenTelemetry. Point them at Prometheus + Grafana with:

export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
python flow.py run

Install

# Core (CPU, memory, disk, duration)
pip install metaflow-observability

# With GPU support (NVIDIA only, requires CUDA drivers)
pip install "metaflow-observability[gpu]"

Usage

Zero-config with Prometheus

Add @observability to any step. By default, metrics are scraped via a Prometheus endpoint on port 8000.

@observability
@step
def preprocess(self):
    ...

Custom OTel backend

Use any OpenTelemetry-compatible backend (Grafana Cloud, Datadog, Honeycomb, etc.) via standard OTel environment variables:

export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.example.com
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <token>"

GPU metrics

Install the GPU extra and run on a CUDA-enabled machine — GPU utilization and memory are collected automatically per device, tagged with gpu_index.

pip install "metaflow-observability[gpu]"

How it works

@observability wraps task_pre_step / task_post_step / task_exception hooks in Metaflow's decorator API. Before your step code runs, it starts background threads that sample CPU%, RSS memory, disk I/O throughput, and (optionally) GPU utilization at 1-second intervals. When the step finishes, samples are aggregated and exported as OpenTelemetry instruments:

Metric Instrument Tags
step.duration Histogram (seconds) step, flow, run_id, retry
step.cpu.pct Gauge (avg / max / p95) same
step.memory.mb Gauge (avg / max RSS) same
step.disk.read_bytes Counter same
step.disk.write_bytes Counter same
step.disk.read_throughput Gauge (MB/s) same
step.disk.write_throughput Gauge (MB/s) same
step.gpu.utilization Gauge + gpu_index
step.gpu.memory.used_mb Gauge + gpu_index
step.retries Gauge same
step.failures Counter same

Configuration

All configuration is via standard OpenTelemetry environment variables. No extension-specific config needed.

Variable Purpose
OTEL_EXPORTER_OTLP_ENDPOINT OTLP endpoint for traces and metrics
OTEL_EXPORTER_OTLP_HEADERS Auth headers (e.g., Authorization=Bearer ...)
OTEL_SERVICE_NAME Service name tag on all metrics

If neither variable is set, metrics are printed to stdout via the OTel console exporter (useful for local debugging).

Development

git clone https://github.com/npow/metaflow-observability
cd metaflow-observability
pip install -e ".[dev]"

# Run tests
pytest

# Lint + format
ruff check src tests
ruff format src tests

# Type check
mypy

CI runs the full suite across Python 3.9, 3.10, 3.11, and 3.12 on every push.

License

Apache-2.0

Metadata

Release files for metaflow-observability 0.1.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 metaflow-observability 0.1.0
File Size Uploaded Provenance
metaflow_observability-0.1.0.tar.gz 16.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for metaflow-observability 0.1.0
File Interpreter ABI Platform
metaflow_observability-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.6 kB

Release files / metaflow_observability-0.1.0.tar.gz

Download URL metaflow_observability-0.1.0.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6883bcfe07a1587ece692bb46dac0cf0338f1d921aa943cdadafd313ba3efb90
BLAKE2b-256 checksum
How to use checksums
0d1f9a048ab392c9eeeffd74b1aa07ba2f1d04f247c6d4416ba777cf2d4198f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.

Transparency log

Release files / metaflow_observability-0.1.0-py3-none-any.whl

Download URL metaflow_observability-0.1.0-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d322c89d40c2fbf92f7a77e1a77d1904dc894802e26ec857d58eb99c24d007f
BLAKE2b-256 checksum
How to use checksums
f182766185a463640b8257c487e19cbf097b4f758718bf8252e60b0d18b7a986
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.

Transparency log

Security for metaflow-observability 0.1.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for metaflow_observability-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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