Class: ChronoForge::Executor::ExecutionTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/chrono_forge/executor/execution_tracker.rb

Constant Summary collapse

MAX_CONTEXT_BYTESIZE =

Total budget for the context snapshot copied into each error log. Transient errors can be logged repeatedly (one row per retry), and the full context always remains on the workflow itself, so the error copy only needs to be a bounded diagnostic breadcrumb. Keys are preserved; values are kept until the running total would exceed this budget, after which each remaining value is replaced by OMITTED_VALUE. Per-value size is already bounded by Context validation, so no per-value truncation is needed here — a single value larger than the budget is simply replaced.

64.kilobytes
OMITTED_VALUE =

Placeholder stored in place of a value that didn’t fit the budget.

"<<omitted>>"

Class Method Summary collapse

Class Method Details

.track_error(workflow, error, execution_log: nil, attempt: nil) ⇒ Object

Parameters:

  • execution_log (ExecutionLog, nil) (defaults to: nil)

    the step the error occurred in, if any. Its step_name and attempt count are recorded on the error log so errors can be attributed to a step and ordered within the workflow.

  • attempt (Integer, nil) (defaults to: nil)

    explicit attempt number for errors not tied to a step (e.g. a workflow-level failure). Falls back to the execution log’s attempt count.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chrono_forge/executor/execution_tracker.rb', line 23

def self.track_error(workflow, error, execution_log: nil, attempt: nil)
  ErrorLog.create!(
    workflow: workflow,
    step_name: execution_log&.step_name,
    attempt: attempt || execution_log&.attempts,
    error_class: error.class.name,
    error_message: error.message,
    backtrace: error.backtrace&.join("\n"),
    context: error_context(workflow.context)
  )
end