Skip to main content

Node

Palette supports node behind a flag. At Palette, we use the Node integration to monitor our own backend performance.

Install

npm install @palette.dev/node

Usage

import { init, network, markers, profiler } from "@palette.dev/node";

init({
key: "<YOUR CLIENT KEY>",
plugins: [network(), markers(), profiler()],
});

// Auto instrumentation of API route handlers
export const handler = async (event, context) => {
// Some expensive work...

// Profiler automatically stops at the end of this handler
return {
statusCode: 200,
body: JSON.stringify({ message: "Hello World" }),
};
};

Measuring Latency

In Next.js, API route latency is automatically collected. To add this metric to your dashboard, go to your project's dashboard > Select All Metrics > Select Mark and Measure > Select api.response.

You can also use the mark and measure APIs to measure the duration of database queries, network requests, and other potentially slow operations.

Here is an example of measuring the duration of a database query:

pages/api/some-route.js
import { mark, measure } from "@palette.dev/node";

const handler = async (req, res) => {
mark("my-query.start");
await db.query("select * from some_table where id = 1");
measure("my-query.total", "my-query.start");

// ...
};
© 2025 Redraw, Inc.