ENG-13798: workflow traces show each start, run, deliver and cancel call and what it did
Until now start, run, deliver and cancel left nothing in a trace but the traceparent they stamp into the stored arguments: whether a start inserted or found the run already there, how many runs a run or cancel matched, and whether a delivery was accepted were returned to the caller only, and a step's span linked to the whole handler around the call.
Each of the four calls is now a PRODUCER span in the caller's context:
| span | attributes |
|---|---|
reflex.workflow.start | reflex.workflow.table, reflex.workflow.step, reflex.workflow.started (false on a unique-constraint hit) |
reflex.workflow.run | table, step, reflex.workflow.rows (runs matched) |
reflex.workflow.deliver | table, step, reflex.workflow.restart, reflex.workflow.rows (runs that accepted) |
reflex.workflow.cancel | table, reflex.workflow.rows (runs matched) |
The span is current while the statement encodes its arguments, so the stored traceparent, and with it the attempt span's link, names the call that scheduled the step. A call that raises (e.g. RunConflict) ends its span with the error.
A reflex.workflow.operations counter ({operation}) on the reflex_workflow meter counts completed calls by reflex.workflow.operation, table, step and reflex.workflow.result (started/exists, matched/none, accepted/refused). otel.enable() takes a meter_provider, defaulting to the global one.
Choices the ticket left open:
- The counter's attributes use the same
reflex.workflow.*keys as the spans rather than baretable/step. - The ticket mentions identifiers "when that opt-in is on"; no such opt-in exists yet, so none are recorded. Whoever adds the opt-in can add them here.
- A call that raises is not counted; its span carries the error.
cancelhas no step, so its span and count carry none.reflex-oteldoesn't forward a meter provider yet, so the counter goes to the global one; a sibling ticket (ENG-13797) owns that wiring.
Tests: under the Postgres fixture (both engine backends), each call's span with the value it returned for every outcome (inserted / exists, rows matched / none, accepted / refused, restart), the stored traceparent naming the start span, a RunConflict start as an error span that counts nothing, and the existing runner test now checking the attempt links to the start span under the handler. The full tests/units/reflex_workflow and reflex_otel suites pass locally (1274 passed).
Linear: ENG-13798
š¤ Generated with Claude Code