@vight/node

Node.js

Use @vight/node for ordinary Node.js services that need traces, runtime metrics, and logs.

Node.jsnpmOpenTelemetry

Integration model

@vight/node is the base runtime package for Node.js services. It should start before the service handles traffic so auto-instrumentation, runtime signals, and log correlation can share the same active context.

Use preload mode when you want Vight to start before your application module is imported. Use programmatic startup when the service already has an explicit bootstrap file and you want configuration to live in code.

Install

Terminal
npm install @vight/node

Preload usage

Preload mode starts Vight before your application module runs. It is the safest option for existing Node services because instrumentation is active before application imports, route registration, and request handling begin.

Terminal
VIGHT_SERVICE_NAME=api \
VIGHT_INGESTION_KEY=... \
VIGHT_OTLP_ENDPOINT=https://ingest.vight.dev \
node --import @vight/node/register server.js

Programmatic usage

Programmatic startup is useful when your service has a controlled bootstrap path. Start Vight before creating listeners, background tasks, schedulers, or framework handlers that should be traced.

server.ts
import { createVightLogger, startVight } from "@vight/node";

await startVight({
  serviceName: "api",
  environment: "production",
  captureConsoleLogs: true,
});

const logger = createVightLogger("billing");

logger.info("invoice_paid", {
  plan: "team",
});

Choosing a startup mode

Preload
Best for broad auto-instrumentation and services where request-handling modules are imported immediately.
Programmatic
Best when configuration is assembled in a bootstrap file and startup order is explicit.
Logger
Use the Vight logger or console capture when logs should correlate with active request traces.