1. Tương thích

  • NodeJs 14+

2. Hướng dẫn tích hợp

Bước 1: Cài đặt thư viện

npm install --save @opentelemetry/api@^1.9.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.53.0

Bước 2: Export biến môi trường

export OTEL_SERVICE_NAME=<app_name>
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs-xxx.apm.vnptplatform.vn/otlp/v1/logs
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://traces-xxx.apm.vnptplatform.vn/v1/traces
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metrics-xxx.apm.vnptplatform.vn/otlp/v1/metrics
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf      
export OTEL_LOGS_EXPORTER="otlp
export OTEL_TRACES_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="Authorization=xxx"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=xxx"
export OTEL_EXPORTER_OTLP_METRICS_HEADERS="Authorization=xxx"
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"

Bước 3: Cấu hình biến môi trường

OTEL_SERVICE_NAME=<app_name>
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://logs-xxx.apm.vnptplatform.vn/otlp/v1/logs
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://traces-xxx.apm.vnptplatform.vn/v1/traces
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metrics-xxx.apm.vnptplatform.vn/otlp/v1/metrics
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf      
OTEL_LOGS_EXPORTER=otlp
OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_LOGS_HEADERS="Authorization=xxx"
OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=xxx"
OTEL_EXPORTER_OTLP_METRICS_HEADERS="Authorization=xxx"