Skip to main content
Version: 2.0.0

PipelineRun class - measure()

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

measure()

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

Arguments

func

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

inputs

The parameters to the function. The inputs are passed to the function as arguments.

stepInfo

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().

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],
);