Install
Use Node.js 22.15 or later. Install the SDK in your application:@opentelemetry/api peer dependency automatically. If your application imports that package directly, install @opentelemetry/api@~1.9.1; version 1.10 is outside this SDK’s supported range.
Configure your destination
Set the environment variables before starting your application. Use a base OTLP HTTP endpoint without/v1/traces, /v1/logs, or /v1/metrics; exporters append those paths.
- Fully managed
- Self-managed
Open Team Settings → Data → Managed Telemetry and copy the OTLP HTTP endpoint and API key. Use the exact HTTPS endpoint and port shown for your service:
Start your application
Preload the SDK before your application imports the libraries it instruments:server.js with your application’s entry file. This command loads the SDK before your application starts and uses the environment variables configured above. It supports CommonJS and ES module applications.
You can now verify ingestion. The alternatives below are only needed if you want to start through an npm script or configure the SDK in code.
Alternative startup methods
Alternative startup methods
--require is also supported. If you use NODE_OPTIONS, scope it to the application command so build tools do not start their own telemetry pipelines:init above static imports in the same file does not guarantee initialization order.Verify ingestion
Start your application, make requests to an instrumented route, and emit a console message. In ClickHouse Observability, select a recent time range and search Logs or Traces formy-node-app. Allow time for the metrics export interval before checking metrics.
If data is missing, check SDK diagnostics on stderr, the endpoint and authentication, and network connectivity. Ensure instrumentation loads before application dependencies. Bundled libraries cannot be automatically instrumented if the bundler inlines them; keep the SDK and instrumented dependencies external. Consult SDK compatibility for TypeScript, ES module, framework, and bundler requirements.
Configure instrumentation
Standard OpenTelemetry environment variables retain their upstream meaning, including sampling, batching, exporters, and resource attributes. For example:Initialization options
Pass these options toinit in your instrumentation module:
Unset or blank environment variables allow the corresponding option to take effect. To disable console capture, include
console in OTEL_NODE_DISABLED_INSTRUMENTATIONS. See the Node.js SDK reference for all defaults.
For explicit process exits or AWS Lambda handlers, see the SDK lifecycle documentation.
Using the upstream SDK
If your application already configures OpenTelemetry, or needs custom processors or behavior outside the ClickStack SDK’s options, use the upstreamNodeSDK and configure OTLP export for the destination above. Follow the upstream SDK setup example, which explains the additional loader and lifecycle configuration. Do not initialize both SDKs in the same process.
Migrating from the HyperDX Node.js SDK
Replace@hyperdx/node-opentelemetry with @clickhouse/clickstack-node and use the new registration entry point. Replace HYPERDX_API_KEY with OTEL_EXPORTER_OTLP_HEADERS, using the authorization format for your destination above.
The new SDK does not preserve every HyperDX helper or option. Review the SDK migration guide before replacing logger integrations, error handlers, custom trace attributes, or sampling settings.