Isolate cost accounting for prepared executions

This commit is contained in:
2026-11-22 18:30:02 +00:00
parent d77e3e2f83
commit ba4de9d11e
4 changed files with 138 additions and 1 deletions

View File

@@ -110,6 +110,8 @@ func (r *Runner) RunPrepared(ctx context.Context, prepared *PreparedExecution) (
return nil, err
}
defer payload.clear()
cost := &observation.CostAccumulator{}
ctx = observation.WithCostAccumulator(ctx, cost)
scope := NewOperationScope(ctx, payload.operationTimeout)
defer scope.Close()
defer func() { err = scope.Finalize(err) }()
@@ -121,6 +123,7 @@ func (r *Runner) RunPrepared(ctx context.Context, prepared *PreparedExecution) (
if observer != nil {
var idErr error
recorder, idErr = observation.New(observer)
recorder.SetCostAccumulator(cost)
recorder.SetParentRunID(payload.parent.RunID())
observation.RegisterClaim(ctx, recorder)
ctx = observation.WithRecorder(ctx, recorder)