Skip to content

Node.js

Instrumenting your existing Node.js application with the OpenTelemetry SDK gives you the flexibility to capture custom metrics, manual spans, and tailored application context.

Install the required OpenTelemetry packages for Node.js:

npm install @opentelemetry/api \
  @opentelemetry/sdk-node \
  @opentelemetry/auto-instrumentations-node \
  @opentelemetry/exporter-trace-otlp-http

Point your OpenTelemetry SDK exporter to the KloudMate Agent’s OTLP endpoint. By default, the KloudMate agent listens on port 4318 for HTTP OTLP traffic.

export OTEL_EXPORTER_OTLP_ENDPOINT="http://KM_AGENT_HOST:4318"
export OTEL_SERVICE_NAME="your-node-service"
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"

(Replace KM_AGENT_HOST with the IP address or hostname of your KloudMate Agent).

OpenTelemetry is continuously evolving. For the most up-to-date SDK instructions, advanced configurations, and custom instrumentation details, refer to the official OpenTelemetry documentation:


Looking for a step-by-step tutorial?
Check out our Instrument a Node.js App guide to see how to build and instrument a simple Express application from scratch.