Skip to main content
MlflowTraceProcessor implements the TraceProcessor ABC and streams QitOS run data to an MLflow tracking server. Once attached, it automatically logs per-span metrics during the run and writes a final summary when the trace ends.

Installation

This installs the mlflow SDK as an optional dependency. Without it, importing MlflowTraceProcessor raises an ImportError.

Quick start

When the run starts, MlflowTraceProcessor calls mlflow.set_experiment() and mlflow.start_run() with the provided arguments. When the trace ends (either normally or on error), it writes a summary and calls mlflow.end_run() by default.

Constructor parameters


What gets logged

Per-span metrics

The processor intercepts span-end events and logs metrics incrementally during the run. Tool names and action names are recorded as MLflow tags rather than metrics, since they are string values.

Final summary

When the trace ends, the processor writes aggregate metrics to the MLflow run:

Using with a local tracking server

Start an MLflow tracking server locally, then point the processor at it:
If tracking_uri is not set, MLflow defaults to the local mlruns directory.

Combining with other processors

add_trace_processor appends to the global processor list, so you can combine MlflowTraceProcessor with any other TraceProcessor, including WandbTraceProcessor:
To replace all processors (removing the default writer), use set_trace_processors:

Lifecycle control

auto_end_run

By default, auto_end_run=True and the processor calls mlflow.end_run() automatically when on_trace_end fires. Set auto_end_run=False if you want to continue logging custom metrics to the same MLflow run after the QitOS trace ends:

shutdown()

Call shutdown() to close the MLflow run early (for example, on SIGTERM or in a notebook cleanup step):
This calls mlflow.end_run() if a run is active and auto_end_run is True. It is safe to call multiple times.

force_flush()

Call force_flush() to ensure all buffered metrics are written to the MLflow tracking server:
This flushes any pending metrics in the MLflow client buffer.