Skip to content

Commit

Permalink
APM OpenTelemetry Cookbooks
Browse files Browse the repository at this point in the history
* Fix 102
* Fix 103
* Fix 104
* Fix 105 go
* Fix 106 java
* Fix 107 nodejs
* Fix 108 nodejs
* Fix 109 go
* Fix 110 php
* FIx 111 java
* Fix 201
* Fix 202
* Fix 203
  • Loading branch information
gwenblum authored Oct 4, 2024
1 parent 5f66622 commit 2d78c3c
Show file tree
Hide file tree
Showing 44 changed files with 486 additions and 388 deletions.
14 changes: 7 additions & 7 deletions APM/102-opentelemetry-spring-demo-app/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 102-opentelemetry-spring-demo-app

This cookbook sets up a Java microservices application with the [APM OpenTelemetry collector container](https://hub.docker.com/r/aternity/apm-collector) on a Docker host to start practicing Digital Experience Monitoring (DEM) using [APM](https://www.riverbed.com/products/application-performance-monitoring/) and [OpenTelemetry](https://opentelemetry.io/).
This cookbook sets up a Java microservices application with the [APM OpenTelemetry collector container](https://hub.docker.com/r/aternity/apm-collector) on a Docker host to start using [APM](https://www.riverbed.com/products/application-performance-monitoring/) and [OpenTelemetry](https://opentelemetry.io/).

The sample app is the famous Java Community application called [Spring PetClinic Microservices](https://github.com/spring-petclinic/spring-petclinic-microservices). Composed of multiple services that run in containers, like Config, Discovery Server, Customers, Vets, Visits and API, it uses [ZipKin](https://zipkin.io/) instrumentation to export some application telemetry (traces for the service calls). The [APM OpenTelemetry collector](https://hub.docker.com/r/aternity/apm-collector) is integrated in the architecture, it also runs in a container, taking the role of the Tracing Server to collect and store the telemetry in the APM backend (SaaS).

Expand Down Expand Up @@ -34,14 +34,14 @@ In this YAML file, the *tracing-server* section contains the APM OpenTelemetry C
container_name: tracing-server
mem_limit: 128M
environment:
- SERVER_URL=wss://${ATERNITY_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${ATERNITY_CUSTOMER_ID}
- SERVER_URL=wss://${RIVERBED_APM_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${ATERNITY_CUSTOMER_ID}
ports:
- 9411:9411
```
### Step 3 - Start the `spring-petclinic-microservices` app

In a shell, just go in the folder where you keep the [docker-compose.yml](docker-compose.yml). Configure the APM OpenTelemetry Collector using the environment variable, ATERNITY_SAAS_SERVER_HOST and ATERNITY_CUSTOMER_ID, and starts all the containers with docker-compose.
In a shell, just go in the folder where you keep the [docker-compose.yml](docker-compose.yml). Configure the APM OpenTelemetry Collector using the environment variable, RIVERBED_APM_SAAS_SERVER_HOST and RIVERBED_APM_CUSTOMER_ID, and starts all the containers with docker-compose.

For example, using Bash:

Expand All @@ -50,8 +50,8 @@ For example, using Bash:
cd Riverbed-Community-Toolkit/APM/102-opentelemetry-spring-demo-app
# Configure the environment variables for the APM OpenTelemetry Collector
export ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
export ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
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
Expand All @@ -64,8 +64,8 @@ or else using PowerShell:
cd Riverbed-Community-Toolkit/APM/102-opentelemetry-spring-demo-app
# Configure the environment variable for the APM OpenTelemetry Collector
$env:ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
$env:ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
$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
Expand Down
147 changes: 106 additions & 41 deletions APM/102-opentelemetry-spring-demo-app/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Riverbed-Community-Toolkit
# 102-opentelemetry-spring-demo-app
# version: 22.3.31
# version: 24.10.4
#
# Define the containers of the Spring PetClinic Microservices application using APM OpenTelemetry Collector for the tracing-server
# Reference:
Expand All @@ -12,103 +12,168 @@
# docker-compose up
#
# Example in PowerShell
# $env:ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
# $env:ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
# $env:RIVERBED_APM_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
# $env:RIVERBED_APM_CUSTOMER_ID="12341234-12341234-13241234"
# docker-compose up
#
# Example in Unix
# ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com" ATERNITY_CUSTOMER_ID="12341234-12341234-13241234" docker-compose up
# RIVERBED_APM_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com" RIVERBED_APM_CUSTOMER_ID="12341234-12341234-13241234" docker-compose up
#

version: '3.8'

services:

tracing-server:
image: aternity/apm-collector
image: aternity/apm-collector:2022.11.0-4
container_name: tracing-server
mem_reservation: 20M
mem_limit: 128M
mem_reservation: 50M
mem_limit: 200M
environment:
- SERVER_URL=wss://${ATERNITY_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${ATERNITY_CUSTOMER_ID}
- SERVER_URL=wss://${RIVERBED_APM_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${RIVERBED_APM_CUSTOMER_ID}
ports:
- 9411:9411
healthcheck:
test: ["CMD", "nc", "-zv", "localhost","9411"]
interval: 1m
timeout: 10s
retries: 6
start_period: 10s
start_interval: 5s

config-server:
image: springcommunity/spring-petclinic-config-server
image: springcommunity/spring-petclinic-config-server:2.5.1
container_name: config-server
mem_reservation: 200M
mem_limit: 256M
mem_limit: 500M
ports:
- 8888:8888
healthcheck:
test: ["CMD", "curl", "-f", "http://config-server:8888"]
interval: 1m
timeout: 10s
retries: 6
start_period: 30s
start_interval: 10s

discovery-server:
image: springcommunity/spring-petclinic-discovery-server
image: springcommunity/spring-petclinic-discovery-server:2.5.1
container_name: discovery-server
mem_reservation: 200M
mem_limit: 256M
mem_limit: 500M
depends_on:
- config-server
entrypoint: ["./dockerize","-wait=tcp://config-server:8888","-timeout=60s","--","java","-Xmx128m","-XshowSettings:vm","org.springframework.boot.loader.JarLauncher"]
config-server:
condition: service_healthy
ports:
- 8761:8761
environment:
- JAVA_TOOL_OPTIONS=-Xmx128m
healthcheck:
test: ["CMD", "curl", "-f", "http://discovery-server:8761"]
interval: 1m
timeout: 10s
retries: 6
start_period: 60s
start_interval: 60s

customers-service:
image: springcommunity/spring-petclinic-customers-service
image: springcommunity/spring-petclinic-customers-service:2.5.1
container_name: customers-service
mem_reservation: 200M
mem_limit: 256M
mem_limit: 500M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java","-Xmx128m","-XshowSettings:vm","org.springframework.boot.loader.JarLauncher"]
tracing-server:
condition: service_healthy
discovery-server:
condition: service_healthy
config-server:
condition: service_healthy
environment:
- JAVA_TOOL_OPTIONS=-Xmx128m
- SPRING_PROFILES_ACTIVE=docker
ports:
- 8081:8081
healthcheck:
test: ["CMD", "curl", "-f", "http://customers-service:8081"]
interval: 1m
timeout: 10s
retries: 10
start_period: 60s
start_interval: 60s

visits-service:
image: springcommunity/spring-petclinic-visits-service
image: springcommunity/spring-petclinic-visits-service:2.5.1
container_name: visits-service
mem_reservation: 200M
mem_limit: 256M
mem_limit: 500M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java","-Xmx128m","-XshowSettings:vm","org.springframework.boot.loader.JarLauncher"]
tracing-server:
condition: service_healthy
discovery-server:
condition: service_healthy
config-server:
condition: service_healthy
ports:
- 8082:8082
environment:
- JAVA_TOOL_OPTIONS=-Xmx128m
healthcheck:
test: ["CMD", "curl", "-f", "http://visits-service:8082"]
interval: 1m
timeout: 10s
retries: 10
start_period: 60s
start_interval: 60s

vets-service:
image: springcommunity/spring-petclinic-vets-service
image: springcommunity/spring-petclinic-vets-service:2.5.1
container_name: vets-service
mem_reservation: 200M
mem_limit: 256M
mem_limit: 500M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java","-Xmx256m","-XshowSettings:vm","org.springframework.boot.loader.JarLauncher"]
tracing-server:
condition: service_healthy
discovery-server:
condition: service_healthy
config-server:
condition: service_healthy
ports:
- 8083:8083
environment:
- JAVA_TOOL_OPTIONS=-Xmx256m
healthcheck:
test: ["CMD", "curl", "-f", "http://vets-service:8083"]
interval: 1m
timeout: 10s
retries: 10
start_period: 60s
start_interval: 60s

api-gateway:
image: springcommunity/spring-petclinic-api-gateway
image: springcommunity/spring-petclinic-api-gateway:2.5.1
container_name: api-gateway
mem_reservation: 200M
mem_limit: 300M
mem_limit: 500M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java","-Xmx128m","-XshowSettings:vm","org.springframework.boot.loader.JarLauncher"]
tracing-server:
condition: service_healthy
discovery-server:
condition: service_healthy
environment:
- JAVA_TOOL_OPTIONS=-Xmx128m
ports:
- 8080:8080


admin-server:
image: springcommunity/spring-petclinic-admin-server
image: springcommunity/spring-petclinic-admin-server:2.5.1
container_name: admin-server
mem_reservation: 200M
mem_limit: 256M
mem_limit: 500M
depends_on:
- config-server
- discovery-server
entrypoint: ["./dockerize","-wait=tcp://discovery-server:8761","-timeout=60s","--","java","-Xmx128m","-XshowSettings:vm","org.springframework.boot.loader.JarLauncher"]
tracing-server:
condition: service_healthy
discovery-server:
condition: service_healthy
config-server:
condition: service_healthy
ports:
- 9090:9090
10 changes: 5 additions & 5 deletions APM/103-opentelemetry-otlp-python-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Those information are required to activate the APM OpenTelemetry Collector conta

Get a local copy of the [docker-compose.yaml](docker-compose.yaml) file.

Edit the file if you want to manually configure the `SERVER_URL` variable, replacing *ATERNITY_SAAS_SERVER_HOST* and *ATERNITY_CUSTOMER_ID* with actual values. The remaining is all set to pull the container image from [DockerHub](https://hub.docker.com/r/aternity/apm-collector) and receive telemetry on the OTLP gRPC port (4317 tcp port 4317.
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](https://hub.docker.com/r/aternity/apm-collector) and receive telemetry on the OTLP gRPC port (4317 tcp port 4317.

```yaml
services:
Expand Down Expand Up @@ -54,8 +54,8 @@ For example using Bash:
cd Riverbed-Community-Toolkit/APM/103-opentelemetry-otlp-python-app

# Configure the environment variables for the APM OpenTelemetry Collector
export ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
export ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
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
Expand All @@ -68,8 +68,8 @@ Using PowerShell:
cd Riverbed-Community-Toolkit/APM/103-opentelemetry-otlp-python-app
# Configure the environment variable for the APM OpenTelemetry Collector
$env:ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
$env:ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
$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
Expand Down
14 changes: 6 additions & 8 deletions APM/103-opentelemetry-otlp-python-app/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
#
# Riverbed-Community-Toolkit
# 103-opentelemetry-otlp-python-app
# version: 24.2.5
# version: 24.10.3
#
# Usage
# docker compose up
#
# Example in Bash
# export ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
# export ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
# export RIVERBED_APM_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
# export RIVERBED_APM_CUSTOMER_ID="12341234-12341234-13241234"
# docker compose up
#
# Example in PowerShell
# $env:ATERNITY_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
# $env:ATERNITY_CUSTOMER_ID="12341234-12341234-13241234"
# $env:RIVERBED_APM_SAAS_SERVER_HOST="agents.apm.myaccount.aternity.com"
# $env:RIVERBED_APM_CUSTOMER_ID="12341234-12341234-13241234"
# docker compose up

version: "3.8"

services:

opentelemetry-collector:
Expand All @@ -32,7 +30,7 @@ services:

environment:

SERVER_URL: "wss://${ATERNITY_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${ATERNITY_CUSTOMER_ID}"
SERVER_URL: "wss://${RIVERBED_APM_SAAS_SERVER_HOST}/?RPM_AGENT_CUSTOMER_ID=${RIVERBED_APM_CUSTOMER_ID}"

ports:

Expand Down
9 changes: 3 additions & 6 deletions APM/104-opentelemetry-zipkin-nodejs-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Riverbed-Community-Toolkit
# 104-opentelemetry-zipkin-nodejs-app
# version: 22.2.24
# version: 24.10.3
#
# Dockerfile for service104-js
#
Expand All @@ -12,7 +12,7 @@
#
# - Run
#
# docker run -it -e OTEL_SERVICE_NAME="service104-js" -e OTEL_EXPORTER_ZIPKIN_ENDPOINT="http://aternity-opentelemetry-collector:9411/api/v2/spans" local/service104-js:latest
# docker run -it -e OTEL_SERVICE_NAME="service104-js" -e OTEL_EXPORTER_ZIPKIN_ENDPOINT="http://riverbed-apm-opentelemetry-collector:9411/api/v2/spans" local/service104-js:latest

FROM node:alpine

Expand All @@ -28,10 +28,7 @@ RUN npm install @opentelemetry/exporter-zipkin
RUN npm install express axios
COPY *.js ./

# TODO: remove this patch when docker build "subdir not supported yet" issue is fixed
COPY 104-opentelemetry-zipkin-nodejs-app/*.js ./

ENV OTEL_SERVICE_NAME="service104-js"
ENV OTEL_EXPORTER_ZIPKIN_ENDPOINT="http://aternity-opentelemetry-collector:9411/api/v2/spans"
ENV OTEL_EXPORTER_ZIPKIN_ENDPOINT="http://riverbed-apm-opentelemetry-collector:9411/api/v2/spans"

CMD [ "node" , "-r" , "./trace_app_with_opentelemetry.js" , "app.js" ]
Loading

0 comments on commit 2d78c3c

Please sign in to comment.