Skip to content

Javascript NodeJS

You can setup tracing for your Node.js application. Check sample configuration on how to setup traces.


git clone

If you don't have node.js installed, please install it and then follow below steps.

Open tracing.js file from that repository. and make changes to the highlighted lines below

const opentelemetry = require("@opentelemetry/sdk-node");
const {
} = require("@opentelemetry/auto-instrumentations-node");
const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
const {
} = require("@opentelemetry/exporter-trace-otlp-http");

// For troubleshooting, set the log level to DiagLogLevel.DEBUG
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

const sdk = new opentelemetry.NodeSDK({
  // traceExporter: new opentelemetry.tracing.ConsoleSpanExporter(),
  traceExporter: new opentelemetry.tracing.ConsoleSpanExporter(),
  traceExporter: new OTLPTraceExporter({
    url: "",
    headers: {
      Authorization: "Authorization",
  instrumentations: [getNodeAutoInstrumentations()],
  serviceName: "nodejs-javascript-service",


Setup up credentials

You will get url and Authorization key here

Replace the url and Authorization key in the tracing.js file

Setup Service/Application

Run commands

npm install
node --require './tracing.js' app.js

The server is now running on 8080, navigate to http://localhost:8080
Refresh page couple of times to get more traces exported.

Traces Sample Configration

Traces are captured, you can check these captured traces here

Traces Page

Filter traces with your service name nodejs-javascript-service

Filter traces with service name

Click on any trace to check trace data

Trace details

Trace can have multiple spans, each span represents single operation or task within that trace. Click on any span to check span details.

Trace details