Skip to main content

Node.js and Sumo Logic

Tracetest is a testing tool based on OpenTelemetry that allows you to test your distributed application. It allows you to use data from distributed traces generated by OpenTelemetry to validate and assert if your application has the desired behavior defined by your test definitions.

Sumo Logic is a cloud-based machine data analytics company focusing on security, operations and BI use-cases. It provides log management and analytics services that use machine-generated big data.

Node.js App with Sumo Logic, OpenTelemetry, and Tracetest

This is a simple quick start on how to configure a Node.js app to use OpenTelemetry instrumentation with traces and Tracetest for enhancing your E2E and integration tests with trace-based testing. The infrastructure will use Sumo Logic as the trace data store, and the Sumo Logic distribution of OpenTelemetry Collector to receive traces from the Node.js app and send them to Sumo Logic.


You can run this example with Docker.

Project Structure

The project contains Tracetest Agent, Sumo Logic OpenTelemetry Collector, and a Node.js app.

1. Tracetest Agent

Install and run Tracetest Agent locally.

tracetest start

Once started, Tracetest Agent will:

  • Expose OTLP ports 4317 (gRPC) and 4318 (HTTP) for trace ingestion.
  • Be able to trigger test runs in the environment where it is running.
  • Be able to connect to a trace data store that is not accessible outside of your environment.

Configure Sumo Logic as a Tracing Backend:

type: DataStore
name: Sumo Logic
type: sumologic
# The URL will differ based on your location. View this
# docs page to figure out which URL you need:
url: ""
# Create your ID and Key under Administration > Security > Access Keys
# in your Sumo Logic account:
accessID: "your-access-id"
accessKey: "your-access-key"
Configure Sumo Logic API and Access
tracetest apply datastore -f ./tracetest.datastore.yaml

2. Node.js App

The Node.js app is a simple Express app, contained in the app.js file.

The OpenTelemetry tracing is contained in the tracing.otel.grpc.js or tracing.otel.http.js files. Traces will be sent to Tracetest Agent.

Here's the content of the tracing.otel.grpc.js file:

const opentelemetry = require('@opentelemetry/sdk-node')
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node')
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');

const sdk = new opentelemetry.NodeSDK({
// OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is passed into "new OTLPTraceExporter" automatically
traceExporter: new OTLPTraceExporter(),
instrumentations: [getNodeAutoInstrumentations()],

Choosing the tracing.otel.grpc.js file will send traces to Tracetest Agent's GRPC.

Configure it an environment variable:

  • Running in Docker: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4317

Enabling the tracer is done by preloading the trace file.

node -r ./tracing.otel.grpc.js app.js

In the package.json you will see two npm scripts for running the respective tracers alongside the app.js.

"scripts": {
"with-grpc-tracer":"node -r ./tracing.otel.grpc.js app.js",
"with-http-tracer":"node -r ./tracing.otel.http.js app.js"

To start the server, run this command:

npm run with-grpc-tracer
# or
npm run with-http-tracer

Run the Node.js App and Sumo Logic OpenTelemetry Collector with Docker Compose

The docker-compose.yaml file and Dockerfile in the root directory are for the Node.js app.

As you can see, the Dockerfile uses the command above.

FROM node:slim
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
CMD [ "npm", "run", "with-grpc-tracer" ]

And, the docker-compose.yaml contains one service for the Node.js app and one service for the Sumo Logic OpenTelemetry Collector.

version: '3'
image: quick-start-nodejs
- "host.docker.internal:host-gateway"
build: .
- "8080:8080"
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-collector:4317

- ./collector.config.yaml:/etc/otel/config.yaml

Traces sent to Sumo Logic from the OpenTelemetry Collector.

The collector.config.yaml configures the OpenTelemetry Collector. It receives traces via either grpc or http. Then, exports them to Sumo Logic via the Sumo Logic extension and an installation_token.

Configure Sumo Logic Installation Token

View the Sumo Logic docs here to learn more about installation tokens.



installation_token: <your-sumologic-installation-token>

extensions: [sumologic]
receivers: [otlp]
exporters: [sumologic]

To start it, run this command:

docker compose build # optional if you haven't already built the image
docker compose up

This will start the Node.js app and Sumo Logic OpenTelemetry Collector and send the traces to Sumo Logic.

Run Tracetest Tests

  1. Open Tracetest

  2. Configure Sumo Logic as a trace data store if you have not already as explained in "1. Tracetest Agent".

  3. Start creating tests! Make sure to use the http://localhost:8080/ URL in your test creation.

    Alternatively, you can import this test as a quick start!

    type: Test
    id: W656Q0c4g
    name: Test API
    description: Test the App.
    type: http
    url: http://localhost:8080
    method: GET
    - key: Content-Type
    value: application/json
    - selector: span[tracetest.span.type="http" name="GET /""/" http.method="GET"]
    - attr:http.status_code = 200
    - attr:tracetest.span.duration < 500ms

Learn More

Feel free to check out our examples in GitHub and join our Slack Community for more info!