Metrics Docs
Quickstart
Create an API token, send your first metric, and verify it in Distlang Metrics.
What you need
- A Distlang account at
dash.distlang.com - An API token from the
Authpage - A JavaScript app, script, worker, or route handler
1. Create an API token
Sign in at dash.distlang.com and open the Auth page.
Create a token and copy it somewhere your app can read it. Distlang currently gives each account one long-lived API token at a time.
2. Install the JavaScript client
npm install @distlang/client
3. Send your first metric
import { createDistlangClient } from "@distlang/client";
const client = createDistlangClient();
const metrics = client.metrics.createRecorder({
accessToken: process.env.DISTLANG_ACCESS_TOKEN,
metricSet: "quickstart-app",
definitions: {
requestCount: "counter",
latencyMs: "histogram",
},
});
metrics.requestCount.inc();
metrics.latencyMs.observe(42);
await metrics.flush();
flush() matters. The recorder buffers rows in memory, so short-lived processes and request handlers should flush before they exit.
4. Open the dashboard
Go back to dash.distlang.com and open Dashboards. After the metric set is visible, open the generated dashboard for quickstart-app.
If you want environment-specific examples next: