recordPlan

suspend fun WarpMetricExporter.recordPlan(draft: Draft<*>, stats: WarpStats, attributes: Map<String, String> = emptyMap(), timestamp: Long = 0)

Records Draft coordination-cost gauges into this WarpMetricExporter.

Computes the us.tractat.kuilt.warp.CoordinationCost from draft and stats, then writes two GAUGE metrics:

namevalue
warp.coordination.volumeestimated elements entering the coordinated stage
warp.coordination.roundsnumber of consensus rounds the draft requires

A plan attribute is added automatically:

  • "unplanned" when Draft.isMonotone is true — no coordination step, so no planning consideration is needed (rounds = 0, volume = 0).

  • "planned" when Draft.isMonotone is false — the draft has a coordination stage; the planner's work is relevant, and the volume reflects filter pushdown.

This lets dashboards compare pre- and post-us.tractat.kuilt.warp.plan volumes: an unoptimised draft records a high volume under plan="planned", while the optimised draft records a lower volume under the same key.

Parameters

draft

The Draft pipeline to cost.

stats

WarpStats sketches used to estimate cardinality at each stage.

attributes

Additional label attributes merged with the auto-computed plan attr.

timestamp

Monotonically increasing timestamp for LWW tiebreaking across replicas. Use Clock.System.now().toEpochMilliseconds() in production; a fixed value in tests.