Instrument
Defined in: packages/engine/src/lib/planner/instrument.ts:39
The telemetry seam of the planner. The Engine takes one from
EngineConfig.instrument (default noopInstrument) and hands it to
every stage as StageContext.instrument.
pipeline wraps each of its stages with Instrument.stage once per request, before running it. Stages and the clients they call report what happens inside them with Instrument.event.
Example
Section titled “Example”const loggingInstrument: Instrument = { stage: (name, stage) => async (input, ctx) => { const started = performance.now(); const result = await stage(input, ctx); console.info('stage', name, performance.now() - started); return result; }, event: (name, attributes) => console.info(name, attributes),};const engine = createEngine({ planner, instrument: loggingInstrument });Methods
Section titled “Methods”event()
Section titled “event()”event(
name,attributes):void
Defined in: packages/engine/src/lib/planner/instrument.ts:55
Reports one thing that happened inside a stage, such as a model call.
Names are dotted lower-case strings owned by the emitter (for example
llm.call). Must not throw.
Parameters
Section titled “Parameters”string
attributes
Section titled “attributes”Returns
Section titled “Returns”void
stage()
Section titled “stage()”stage<
In,Out>(name,stage):Stage<In,Out>
Defined in: packages/engine/src/lib/planner/instrument.ts:49
Wraps one stage of a pipeline for one request. Return stage itself, a
stage that calls through to it (to time or trace it), or a different
stage entirely (for example one that replays a recorded output).
Type Parameters
Section titled “Type Parameters”In
Out
Parameters
Section titled “Parameters”string
The name given with named, or stage-<index> for
an unnamed stage, counting from 0 within its pipeline.
Stage<In, Out>
The stage about to run.
Returns
Section titled “Returns”Stage<In, Out>