Documents
Is there an API or query in DBOS to measure the total duration (in milliseconds) of a workflow step?
Is there an API or query in DBOS to measure the total duration (in milliseconds) of a workflow step?
Type
Answer
Status
Published
Created
Aug 2, 2025
Updated
Oct 30, 2025
Created by
Dosu Bot
Updated by
Dosu Bot

Is there an API or query in DBOS to measure the total duration (in milliseconds) of a workflow step?#

Yes, DBOS now records the start and end times (in milliseconds since the UNIX epoch) for each workflow step. These timestamps are available via the DBOS introspection API and can be used to calculate the duration of any step.

How to Access Step Duration#

When you query for workflow steps using the DBOS API (e.g., DBOS.list_workflow_steps(workflow_id) or the /workflows/:workflow_id/steps endpoint), each step object includes the following fields:

  • started_at_epoch_ms: The timestamp (in milliseconds) when the step started.
  • completed_at_epoch_ms: The timestamp (in milliseconds) when the step completed.

To compute the duration of a step in milliseconds:

duration_ms = step['completed_at_epoch_ms'] - step['started_at_epoch_ms']

Example#

steps = DBOS.list_workflow_steps(workflow_id)
for step in steps:
    duration = step['completed_at_epoch_ms'] - step['started_at_epoch_ms']
    print(f"Step {step['function_name']} took {duration} ms")

Additional Notes#

  • Both started_at_epoch_ms and completed_at_epoch_ms are present for all workflow steps.
  • This enables direct measurement and visualization of step durations without requiring external tracing tools or manual instrumentation.
  • DBOS continues to emit OpenTelemetry traces for integration with observability tools like Jaeger, but step timing is now natively available via the API.

If you have any questions about accessing or interpreting these fields, please refer to the workflow introspection API documentation or contact the DBOS team.