Instrument your Node.js application in Kubernetes
Follow the instructions on this page to instrument your Node.js application running in Kubernetes. Make sure you have already installed the Observe Agent.
-
Add the OpenTelemetry zero-code instrumentation for Node.js.
Run the following commands to add zero-code instrumentation for your Node.js application, meaning you don’t have to modify your application’s source code to collect telemetry:
npm install @opentelemetry/sdk-node \
@opentelemetry/api \
@opentelemetry/auto-instrumentations-node \
@opentelemetry/sdk-metrics \
@opentelemetry/sdk-trace-node
- Set the following environment variables to configure the Node.js instrumentation. Replace the placeholders such as
${YOUR_SERVICE_NAME}with the actual information from your environment.
export OTEL_SERVICE_NAME=${YOUR_SERVICE_NAME}
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment=${YOUR_APP_ENVIRONMENT}
export OTEL_EXPORTER_OTLP_ENDPOINT=http://${YOUR_OBSERVE_AGENT_ENDPOINT}:4318
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
- Run your instrumented app:
node app.js
Updated about 1 month ago