Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/run-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down