MCPcopy Create free account
hub / github.com/cel-expr/cel-go / CostObserver

Function CostObserver

interpreter/runtimecost.go:50–63  ·  view source on GitHub ↗

CostObserver provides an observer that tracks runtime cost.

(opts ...costTrackPlanOption)

Source from the content-addressed store, hash-verified

48
49// CostObserver provides an observer that tracks runtime cost.
50func CostObserver(opts ...costTrackPlanOption) PlannerOption {
51 ct := &costTrackerFactory{}
52 for _, o := range opts {
53 ct = o(ct)
54 }
55 return func(p *planner) (*planner, error) {
56 if ct.factory == nil {
57 return nil, errors.New("cost tracker factory not configured")
58 }
59 p.observers = append(p.observers, ct)
60 p.decorators = append(p.decorators, decObserveEval(ct.Observe))
61 return p, nil
62 }
63}
64
65// costTrackerFactory holds a factory for producing new CostTracker instances on each Eval call.
66type costTrackerFactory struct {

Callers 2

newProgramFunction · 0.92
computeCostFunction · 0.85

Calls 2

decObserveEvalFunction · 0.85
NewMethod · 0.80

Tested by 1

computeCostFunction · 0.68