docs: usage function examples were missing the imports (#2830)

Closes #2828
This commit is contained in:
Matt Aitken
2026-02-04 06:05:59 -08:00
committed by GitHub
parent 8e0034484c
commit 7781e2aad1
+4
View File
@@ -8,6 +8,8 @@ description: "Get compute duration and cost from inside a run, or for a specific
You can get the cost and duration of the current including retries of the same run.
```ts
import { task, usage, wait } from "@trigger.dev/sdk";
export const heavyTask = task({
id: "heavy-task",
machine: {
@@ -87,6 +89,8 @@ console.log("Total cost", totalCost);
You can also wrap code with `usage.measure` to get the cost and duration of that block of code:
```ts
import { usage, logger } from "@trigger.dev/sdk";
// Inside a task run function, or inside a function that's called from there.
const { result, compute } = await usage.measure(async () => {
//...Do something for 1 second