Skip to main content
Version: 4.7.8

PipelineRun class - measure()

The PipelineRun class captures the output for a generative invocation. measure() is a method under this class.

measure() tracks the inputs, outputs and duration it takes to run a step in a generative pipeline.

Examples

typescript
import { Pipeline } from '@gentrace/core';
import { User } from "../models";
 
const pipeline = new Pipeline({
slug: "example-pipeline",
});
 
const runner = pipeline.start();
 
const userId = "550e8400-e29b-41d4-a716-446655440000";
const gentraceOrgId = "c9a646d3-9c61-4cb7-bfcd-ee2522c8f633";
 
const name = await runner.measure(
async (userId, gentraceOrgId) => {
// Custom application logic
const user = await User.findOne({
where: {
id: userId,
orgId: gentraceOrgId,
}
})
return user.name
},
// Inputs must be passed via a dependency array, so Gentrace
// can properly trace the data.
[userId, gentraceOrgId],
);
 

Arguments

func: (...inputs: any[]) => Promise<any>

The asynchronous function to measure. The function can take any number of parameters.

inputs: any[]

These are the arguments to the function passed to measure().

stepInfo: object

An object containing additional information about the step. The most important key/value pair in the stepInfo is the context key, which attaches more metadata to the step.

Read about the typing for the context key here.

Return value

The return value of the function passed to measure().