Skip to main content

metaflow-logs

CI PyPI Python License

A Metaflow extension that ships task stdout and stderr to any OpenTelemetry-compatible backend (Grafana Loki, Datadog, New Relic, Elasticsearch, Honeycomb, …). Each log line is tagged with full task context — flow name, run ID, step name, task ID, attempt — making logs filterable and correlatable from any OTel-aware tool.

Quick start

pip install metaflow-logs

Add the decorator to any step:

from metaflow import FlowSpec, step
from metaflow_extensions.logs.plugins.decorator import LogsDecorator

class MyFlow(FlowSpec):
    @LogsDecorator()
    @step
    def train(self):
        print("epoch 1 complete")
        self.next(self.end)

    @step
    def end(self):
        pass

if __name__ == "__main__":
    MyFlow()

Point it at your OTel collector:

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

Each log line arrives in your backend tagged with:

Attribute Example
metaflow.flow MyFlow
metaflow.run_id 123
metaflow.step train
metaflow.task_id 456
metaflow.attempt 0
metaflow.log_source task or runtime

Configuration

All configuration is via standard OTel environment variables:

Variable Default Purpose
OTEL_EXPORTER_OTLP_ENDPOINT http://localhost:4318 OTel collector endpoint
OTEL_EXPORTER_OTLP_HEADERS — Auth headers (e.g. Authorization=Bearer ...)
OTEL_SERVICE_NAME metaflow Service name in your backend

Falls back to a console exporter if opentelemetry-exporter-otlp-proto-http is not installed.

How it works

Reads Metaflow's structured MFLOG files (MFLOG_STDOUT, MFLOG_STDERR) at step completion and emits each line as an OTel LogRecord. Runtime logs (Metaflow internals) are emitted at DEBUG severity; task logs (your code's stdout/stderr) at INFO.

Development

git clone https://github.com/npow/metaflow-logs
cd metaflow-logs
pip install -e .
pytest tests/ -v

Metadata

Release files for metaflow-logs 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-logs 0.1.0
File Size Uploaded Provenance
metaflow_logs-0.1.0.tar.gz 13.0 kB With provenance Details

Built distribution (wheel)

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

Total release size: 24.1 kB

Release files / metaflow_logs-0.1.0.tar.gz

Download URL metaflow_logs-0.1.0.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
36ecad4148c7b361bf7bc03f42e09ab869e7085112c5edb4b1a6614e14fe0e46
BLAKE2b-256 checksum
How to use checksums
10274b386ff5abb0c0bed31685cf25e709b132edd9467240bf8c546cb49b93c3
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_logs-0.1.0-py3-none-any.whl

Download URL metaflow_logs-0.1.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e726d1ff33530a926dc5af4a1ceab2504dd1b1e0966a9f367bfb7758d37abe72
BLAKE2b-256 checksum
How to use checksums
a163e137ede3e32d3dd9102a6cf049bb0cde7094dc571094d820f77059598940
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-logs 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_logs-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