In this cookbook, the APM collects the telemetry of a nodejs webapp that is instrumented with Zipkin. The APM OpenTelemetry Collector container is deployed next to the web app and collects every trace.
The APM OpenTelemetry Collector can collect OTLP, the OpenTelemetry native telemetry protocols, as well as Jaeger and Zipkin telemetry. Here it collects Zipkin telemetry like in the other Riverbed-Community-Toolkit Cookbook 104 where the app is instrumented with OpenTelemetry.
- an APM account (SaaS)
- a Docker host, for example Docker Desktop
Navigate to APM (for example https://apm.myaccount.aternity.com) > Agents > Install Agents:
- Find your CustomerID, for example 12341234-12341234-13241234
- Grab SaaS Analysis Server Host, for example agents.apm.myaccount.aternity.com
Those information are required to activate the APM OpenTelemetry Collector container, passing via the environment variable SERVER_URL
.
Download a local copy of the docker-compose.yaml file, for example in the directory Tech-Community/108-collect-zipkin-nodejs-app
Start the containers using the docker-compose.yaml, for example with Bash:
cd Riverbed-Community-Toolkit/APM/108-collect-zipkin-nodejs-app
# Configure the environment variables for the APM OpenTelemetry Collector
export RIVERBED_APM_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
export RIVERBED_APM_CUSTOMER_ID="12341234-12341234-13241234"
docker-compose up
or with PowerShell:
cd Riverbed-Community-Toolkit/APM/108-collect-zipkin-nodejs-app
# Configure the environement variable for the APM OpenTelemetry Collector
$env:RIVERBED_APM_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
$env:RIVERBED_APM_CUSTOMER_ID="12341234-12341234-13241234"
docker-compose up
The application should now be running. Every trace is collected by the APM OpenTelemetry Collector.
Navigate to http://localhost:8108/fetch from a browser or call the url from a command line.
For example using curl:
curl http://localhost:8108/fetch
Search transaction, browse the spans for the selected transaction :
Press CTRL + C in the shell where it is running.
Or in a shell, go to the folder where you keep the docker-compose.yaml and run:
docker-compose down
The cookbook contains few files:
- app_with_zipkin.js is a simple web app that listens http request (using Express) and exposes a
/fetch
method. It is instrumentated using Zipkin. - Dockerfile defines the docker image to build integrating the zipkin instrumented libraries for the web app (Express and axios)
- docker-compose.yaml is the main file that defines the multi-containers app with two services: the instrumented nodejs web app and the APM OpenTelemetry Collector
In the docker-compose.yaml, on the APM OpenTelemetry Collector section, the image is set to be downloaded from DockerHub and the port to receive Zipkin telemetry is open.
The only thing that needs to be configured is the SERVER_URL
variable. It contains the Aternity CustomerID and SaaS Analysis Server Host that allow the container to connect to the Aternity SaaS service and get activated. The APM OpenTelemetry Collector section is simple:
services:
opentelemetry-collector:
image: registry.hub.docker.com/aternity/apm-collector:2022.3.0-3
container_name: aternity-opentelemetry-collector
environment:
SERVER_URL: "wss://${RIVERBED_APM_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${RIVERBED_APM_CUSTOMER_ID}"
ports:
- "9411:9411/tcp"
In the docker-compose.yaml above, the SERVER_URL
has been defined by two docker compose variables, to ease external configuration (RIVERBED_APM_SAAS_SERVER_HOST and RIVERBED_APM_CUSTOMER_ID). It can also be hard-coded, like this this:
SERVER_URL: "wss://agents.apm.myaccount.aternity.com/?RPM_AGENT_CUSTOMER_ID=12341234-12341234-13241234"
In the docker-compose.yaml, in the application container section, the ZIPKIN_ENDPOINT
environment variable is used to bind the web app telemetry to the collector container:
service108_js:
environment:
ZIPKIN_ENDPOINT: http://riverbed-apm-opentelemetry-collector:9411/api/v2/spans
ZIPKIN_SERVICE_NAME: service108_js
Copyright (c) 2022-2024 Riverbed Technology, Inc.
The contents provided here are licensed under the terms and conditions of the MIT License accompanying the software ("License"). The scripts are distributed "AS IS" as set forth in the License. The script also include certain third party code. All such third party code is also distributed "AS IS" and is licensed by the respective copyright holders under the applicable terms and conditions (including, without limitation, warranty and liability disclaimers) identified in the license notices accompanying the software.