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.
Prerequisites​
Tracetest Account:
- Sign up to
app.tracetest.io
or follow the get started docs. - Have access to the environment's agent API key.
Sumo Logic Account:
- Sign up to Sumo Logic
- Create a Sumo Logic installation token
- Create a Sumo Logic
accessID
andaccessKey
Docker: Have Docker and Docker Compose installed on your machine.
Run This Quckstart Example​
The example below is provided as part of the Tracetest project. You can download and run the example by following these steps:
Clone the Tracetest project and go to the Sumo Logic Node.js Quickstart:
git clone https://github.com/kubeshop/tracetest
cd tracetest/examples/quick-start-sumologic-nodejs
Follow these instructions to run the quick start:
- Copy the
.env.template
file to.env
. - Fill out the TRACETEST_TOKEN and ENVIRONMENT_ID details by editing your
.env
file. - Fill out the SUMOLOGIC_INSTALLATION_TOKEN, SUMO_LOGIC_ACCESS_ID and SUMO_LOGIC_ACCESS_KEY details by editing your
.env
file. - Run
docker compose run tracetest-run
. - Follow the links in the output to view the test results.
Follow along with the sections below for an in detail breakdown of what the example you just ran did and how it works.
Project Structure​
The project contains Tracetest Agent, OpenTelemetry Collector, and a Node.js app.
The docker-compose.yaml
file in the root directory of the quick start runs the Node.js app and the Tracetest Agent setup.
Configuring the Node.js App​
The Node.js app is a simple Express app, contained in the app.js
file.
Configure the .env
like shown below.
# Get the required information here: https://app.tracetest.io/retrieve-token
TRACETEST_TOKEN="<YOUR_TRACETEST_TOKEN>"
TRACETEST_ENVIRONMENT_ID="<YOUR_ENV_ID>"
# https://help.sumologic.com/docs/manage/security/installation-tokens/
SUMOLOGIC_INSTALLATION_TOKEN="<YOUR_SUMOLOGIC_INSTALLATION_TOKEN>"
# https://help.sumologic.com/docs/manage/security/access-keys/#create-an-access-key
SUMO_LOGIC_ACCESS_ID="<YOUR_SUMO_LOGIC_ACCESS_ID>"
SUMO_LOGIC_ACCESS_KEY="<YOUR_SUMO_LOGIC_ACCESS_KEY>"
The OpenTelemetry tracing is contained in the tracing.otel.grpc.js
or tracing.otel.http.js
files.
Choosing the tracing.otel.grpc.js
file will send traces to Sumo Logic OpenTelemetry Collector's GRPC
endpoint.
Enabling the tracer is done by preloading the trace file. As seen in the package.json
.
"scripts": {
"app-with-grpc-tracer": "node -r ./tracing.otel.grpc.js app.js",
},
Run the Node.js App, Sumo Logic OpenTelemetry Collector, and Tracetest​
The docker-compose.yaml
file and Dockerfile
in the root directory are for the Node.js app.
And, the docker-compose.yaml
contains one service for the Node.js app, one service for the Sumo Logic OpenTelemetry Collector, and one service for Tracetest Agent.
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
.
To start all the services and run Tracetest tests, run this command:
docker compose run tracetest-run
This will:
- This will start the Node.js app and Sumo Logic OpenTelemetry Collector and send the traces to Sumo Logic.
- Start the Tracetest Agent.
- Configure the tracing backend and create tests in your environment.
- Run the tests.
Open the URL and start creating tests! Make sure to use the http://app:8080/
URL in your test creation, because your Node.js app and Tracetest are in the same network.
Learn More​
Feel free to check out our examples in GitHub and join our Slack Community for more info!