Quickstart: Node

Send your first trace from Node or TypeScript.

Fetch example

const API = process.env.INTERTRACE_API_URL;
const KEY = process.env.INTERTRACE_API_KEY;

async function postTrace(body) {
  const res = await fetch(`${API}/api/v1/telemetry/traces`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${KEY}`,
      "Content-Type": "application/json",
      "Idempotency-Key": body.idempotency_key ?? "demo-node-1",
    },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(await res.text());
  return res.json();
}

await postTrace({
  trace: { name: "node_quickstart", metadata: {} },
  spans: [
    {
      name: "hello",
      kind: "chain",
      start_time: new Date().toISOString(),
      end_time: new Date().toISOString(),
      attributes: { note: "first span" },
    },
  ],
});