This cookbook deploys multiple containers using docker-compose: a python web app, that is based on Flask and auto-instrumented using OpenTelemetry to export OLTP telemetry, a simple traffic generator and the APM OpenTelemetry Collector container.
The APM OpenTelemetry Collector is a container that collects the telemetry exported by the application whether using OTLP, the OpenTelemetry native telemetry protocols, Jaeger or Zipkin.
- an APM account (SaaS)
- a Docker host, for example Docker Desktop
Navigate to the APM web console (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 and will be passed via the environment variable SERVER_URL
.
Get a local copy of the docker-compose.yaml file.
Edit the file if you want to manually configure the SERVER_URL
variable, replacing RIVERBED_APM_SAAS_SERVER_HOST and RIVERBED_APM_CUSTOMER_ID with actual values. The remaining is all set to pull the container image from DockerHub and receive telemetry on the OTLP gRPC port (4317 tcp port 4317.
services:
opentelemetry-collector:
image: registry.hub.docker.com/aternity/apm-collector:2022.11.0-4
container_name: apm-collector
environment:
SERVER_URL: "wss://agents.apm.myaccount.aternity.com/?RPM_AGENT_CUSTOMER_ID=12341234-12341234-13241234"
ports:
- "4317:4317/tcp"
Then, start the containers from the shell. The collector can be configured at the same time using environment variables.
For example using Bash:
# Go to the directory that contains docker-compose.yaml
cd Riverbed-Community-Toolkit/APM/103-opentelemetry-otlp-python-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"
# Start the containers
docker compose up
Using PowerShell:
# Go to the directory that contains docker-compose.yaml
cd Riverbed-Community-Toolkit/APM/103-opentelemetry-otlp-python-app
# Configure the environment 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"
# Start the containers
docker compose up
The web app should now be running as well as the traffic generator. Every trace will be collected by the APM OpenTelemetry Collector.
You can also browse the app, navigating to http://localhost:8103/server_request or call the URL from a command line.
For example using curl:
curl http://localhost:8103/server_request
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
On the application container side, the OTEL_EXPORTER_OTLP_ENDPOINT
environment variable is used to bind the web app telemetry exporter to the collector container:
service103_python:
environment:
OTEL_EXPORTER_OTLP_ENDPOINT: http://apm-collector:4317
OTEL_SERVICE_NAME: service103_python
Copyright (c) 2022 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.