The fastest way to instrument any Node.js project. The agent reads your code, detects your framework and libraries, writes the right instrumentation file, and installs packages.
export ROCKETGRAPH_API_KEY=rg_live_xxxxxx  # from rocketgraph.app/settings
npx @rgraph/otel-node init
The agent:
  • Detects your framework (Express, Fastify, Next.js, NestJS, Koa, Hapi, and more)
  • Reads your actual code to understand existing setup
  • Writes an instrumentation.ts (or .js) file in the project root
  • Installs only the OpenTelemetry packages you need
  • Configures traces, metrics, and logs to send to Rocketgraph
  • Bridges console.log/warn/error to OpenTelemetry logs automatically
Supports: Express, Fastify, Next.js, NestJS, Koa, Hapi, Restify. Detects: PostgreSQL, MySQL, MongoDB, Redis, Prisma, TypeORM, Knex, GraphQL, gRPC, AWS SDK, and more.

After running

Next.js: The instrumentation.ts file is auto-loaded — no changes needed. Express / Fastify / plain Node: Import it as the first line of your entry point:
import './instrumentation'  // must be first
import express from 'express'
// ...
Set your environment variables:
export ROCKETGRAPH_API_KEY=rg_live_xxxxxx
export OTEL_SERVICE_NAME=my-service

Fallback: template mode

If you prefer not to use the AI agent:
npx @rgraph/otel-node init --legacy
This uses static detection and template generation without an AI model.

Manual setup

1. Install packages

npm install @opentelemetry/sdk-node @opentelemetry/api \
  @opentelemetry/resources @opentelemetry/semantic-conventions \
  @opentelemetry/auto-instrumentations-node \
  @opentelemetry/exporter-trace-otlp-proto \
  @opentelemetry/exporter-metrics-otlp-proto \
  @opentelemetry/exporter-logs-otlp-proto \
  @opentelemetry/sdk-metrics @opentelemetry/sdk-logs

2. Set environment variables

export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingress.us-east-2.rocketgraph.app"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer rg_live_xxxxxx"
export OTEL_SERVICE_NAME="my-service"

3. Use auto-instrumentation

The simplest approach — no code changes:
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
node app.js
Or create an instrumentation.ts for more control. See the OpenTelemetry Node.js docs for the full SDK setup.

Uninstall

npx @rgraph/otel-node uninstall
Removes the generated instrumentation file and backup. OTel packages are left installed.

Next steps