#
OpenTelemetry for Node.js
The Baselime Node.js OpenTelemetry SDK enables you to instrument your Node.js services with OpenTelemetry without the boilerplate of using the OpenTelemetry SDK directly.
This SDK uses OpenTelemetry for JavaScript and provides a layer that facilitates instrumenting your Node.js applications.
If your application is already instrumented with OpenTelemetry, you can start sending your tracing data to Baselime without any additional code changes.
Add the Baselime OpenTelemetry endpoint to your exporter:
- Endpoint
https://otel.baselime.io/v1/
- Header:
x-api-key: <BASELIME_API_KEY>
#
Instrumentation
#
Step 1: Install the SDKs
Install the Baselime Node.js OpenTelemetry SDK.
npm i --save \
@baselime/node-opentelemetry \
@opentelemetry/auto-instrumentations-node
#
Step 2: Initialise the tracer
Create a tracing.cjs
file inside your application working directory.
const { BaselimeSDK } = require('@baselime/node-opentelemetry');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const sdk = new BaselimeSDK({
instrumentations: [
getNodeAutoInstrumentations(),
],
});
sdk.start();
#
Step 3: Set the Baselime environment variables
Set the environment variables of your comntainer service to include the Baselime API Key and set the NODE_OPTIONS enviroment variable to preload the OpenTelemetry SDK into your application.
Once these steps are completed, distributed traces from your Node.js container applications should be available in Baselime to query via the console or the Baselime CLI.
#
Configuration
The BaselimeSDK
class of the Baselime Node.js OpenTelemetry SDK takes the following configuration options.