Skip to content

Commit 777d056

Browse files
committed
PetClinic loadgen and RUM to APM
1 parent 7845097 commit 777d056

File tree

5 files changed

+47
-22
lines changed

5 files changed

+47
-22
lines changed

content/en/other/pet-clinic/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The goal is to walk through the basic steps to configure the following component
1212
* Database Query Performance
1313
* AlwaysOn Profiling
1414
* Splunk Real User Monitoring (RUM)
15+
* RUM spans to APM spans
1516
* Splunk LogsObserver (LO)
1617

1718
We will also show the steps about how to clone (download) a sample Java application (Spring PetClinic), as well as how to compile, package and run the application.

content/en/other/pet-clinic/apm.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ Next we will clone the PetClinic repository, then we will compile, build, packag
1414
git clone https://github.com/spring-projects/spring-petclinic
1515
```
1616

17-
```bash
18-
git checkout 276880e
19-
```
20-
2117
Change into the `spring-petclinic` directory:
2218

2319
```bash
24-
cd spring-petclinic
20+
cd spring-petclinic && git checkout 276880e
2521
```
2622

2723
Start a MySQL database for PetClinic to use:
@@ -30,21 +26,21 @@ Start a MySQL database for PetClinic to use:
3026
docker run -d -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 docker.io/mysql:5.7.8
3127
```
3228

33-
Next, run the maven command to compile/build/package PetClinic:
29+
Next, run the `maven` command to compile/build/package PetClinic:
3430

3531
```bash
3632
./mvnw package -Dmaven.test.skip=true
3733
```
3834

39-
{{% notice title="Information" style="info" %}}
40-
This will take a few minutes the first time you run, maven will download a lot of dependencies before it actually compiles the app. Future executions will be a lot shorter.
35+
{{% notice title="Note" style="info" %}}
36+
This will take a few minutes the first time you run, `maven` will download a lot of dependencies before it actually compiles the application. Future executions will be a lot shorter.
4137
{{% /notice %}}
4238

4339
Once the compilation is complete, you can run the application with the following command:
4440

4541
```bash
4642
java \
47-
-Dotel.service.name=$(hostname)-petclinic.service \
43+
-Dotel.service.name=$(hostname)-petclinic-service \
4844
-jar target/spring-petclinic-*.jar --spring.profiles.active=mysql
4945
```
5046

@@ -54,37 +50,49 @@ If you check the logs of the Splunk OpenTelemetry collector you will see that th
5450
sudo tail -f /var/log/syslog
5551
```
5652

57-
You can validate if the application is running by visiting `http://<VM_IP_ADDRESS>:8080`. Now generate some traffic, click around, generate errors, add visits, etc. Then you can visit the Splunk APM UI and examine the application components, traces, etc. **Hamburger Menu → APM → Explore**.
53+
You can validate if the application is running by visiting `http://<VM_IP_ADDRESS>:8080`.
54+
55+
## 2. Generating Traffic
56+
57+
Next we will start a Docker container running Locust that will generate some simple traffic to the PetClinic application. Locust is a simple load testing tool that can be used to generate traffic to a web application.
58+
59+
```bash
60+
docker run --network="host" -d -p 8089:8089 -v /home/ubuntu/workshop/locust:/mnt/locust locustio/locust -f /mnt/locust/locustfile.py --headless -u 10 -r 3 -H http://127.0.0.1:8080
61+
```
62+
63+
Then you can visit the Splunk APM UI and examine the application components, traces, etc. **Hamburger Menu → APM → Explore**.
64+
65+
Once your validation is complete you can stop the application by pressing `Ctrl-c`.
5866

59-
**Once your validation is complete you can stop the application by pressing** `Ctrl-c` **.**
67+
## 3. Enabling AlwaysOn Profiling and Metrics
6068

6169
To enable CPU and Memory Profiling on the application we can start the application by passing `splunk.profiler.enabled=true` and for metrics pass `splunk.metrics.enabled=true`. Make sure the application is stopped and run the following command to enable metrics and profiling.
6270

6371
```bash
6472
java \
65-
-Dotel.service.name=$(hostname)-petclinic.service \
73+
-Dotel.service.name=$(hostname)-petclinic-service \
6674
-Dsplunk.profiler.enabled=true \
6775
-Dsplunk.metrics.enabled=true \
6876
-jar target/spring-petclinic-*.jar --spring.profiles.active=mysql
6977
```
7078

71-
Let's go visit our application again to generate some traffic `http://<VM_IP_ADDRESS>:8080`. Click around, generate errors, add visits, etc. Then you can visit the Splunk APM UI and examine the application components, traces, profiling, DB Query performance and metrics **Hamburger Menu → APM → Explore**.
79+
You can now visit the Splunk APM UI and examine the application components, traces, profiling, DB Query performance and metrics **Hamburger Menu → APM → Explore**.
7280

73-
**Once your validation is complete you can stop the application by pressing** `Ctrl-c` **.**
81+
Once your validation is complete you can stop the application by pressing `Ctrl-c`.
7482

75-
## 2. Adding Resource Attributes to Spans
83+
## 4. Adding Resource Attributes to Spans
7684

7785
Resource attributes can be added to every reported span. For example `version=0.314`. A comma separated list of resource attributes can also be defined e.g. `key1=val1,key2=val2`.
7886

7987
Let's launch the PetClinic again using a new resource attribute. Note, that adding resource attributes to the run command will override what was defined when we installed the collector. So, we also need to specify our `deployment.environment` resource attribute along with our new resource attribute. Below you will see we are setting `deployment.environment=$(hostname)-petclinic` and `version=0.314`.
8088

8189
```bash
8290
java \
83-
-Dotel.service.name=$(hostname)-petclinic.service \
91+
-Dotel.service.name=$(hostname)-petclinic-service \
8492
-Dsplunk.profiler.enabled=true \
8593
-Dsplunk.metrics.enabled=true \
8694
-Dotel.resource.attributes=deployment.environment=$(hostname)-petclinic,version=0.314 \
8795
-jar target/spring-petclinic-*.jar --spring.profiles.active=mysql
8896
```
8997

90-
Go back to the application and generate some more traffic. Then, back in the Splunk APM UI we can drill down on a recent trace and see the new `version` attribute in a span.
98+
Back in the Splunk APM UI we can drill down on a recent trace and see the new `version` attribute in a span.

content/en/other/pet-clinic/logobserver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ And then run the application again:
9595

9696
```bash
9797
java \
98-
-Dotel.service.name=$(hostname)-petclinic.service \
98+
-Dotel.service.name=$(hostname)-petclinic-service \
9999
-Dsplunk.profiler.enabled=true \
100100
-Dsplunk.metrics.enabled=true \
101101
-Dotel.resource.attributes=deployment.environment=$(hostname)-petclinic,version=0.314 \

content/en/other/pet-clinic/rum.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@ Let's then edit the layout page:
3939
vi src/main/resources/templates/fragments/layout.html
4040
```
4141

42-
and let's insert the snipped we generated above in the `<head>` section of the page. Now we need to rebuild the application and run it again:
42+
Next, insert the snippet we generated above in the `<head>` section of the page. Now we need to rebuild the application and run it again:
4343

4444
## 2. Rebuild PetClinic
4545

46-
run the maven command to compile/build/package PetClinic:
46+
Run the `maven` command to compile/build/package PetClinic:
4747

4848
```bash
4949
./mvnw package -Dmaven.test.skip=true
5050
```
5151

5252
```bash
5353
java \
54-
-Dotel.service.name=$(hostname)-petclinic.service \
54+
-Dotel.service.name=$(hostname)-petclinic-service \
5555
-Dsplunk.profiler.enabled=true \
5656
-Dsplunk.metrics.enabled=true \
5757
-Dotel.resource.attributes=deployment.environment=$(hostname)-petclinic,version=0.314 \
5858
-jar target/spring-petclinic-*.jar --spring.profiles.active=mysql
5959
```
6060

61-
Then let's visit the application again to generate more traffic `http://<VM_IP_ADDRESS>:8080`, now we should see RUM traces being reported
61+
Then let's visit the application using a browser to generate real-user traffic `http://<VM_IP_ADDRESS>:8080`, now we should see RUM traces being reported.
6262

6363
Let's visit RUM and see some of the traces and metrics **Hamburger Menu → RUM** and you will see some of the Spring PetClinic URLs showing up in the UI.
64+
65+
When you drill down into a RUM trace you will see a link to APM in the spans. Clicking on the trace ID will take you to the corresponding APM trace for the current RUM trace.

workshop/petclinic/locustfile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
from locust import HttpUser, task, between
3+
4+
class QuickstartUser(HttpUser):
5+
wait_time = between(1, 5)
6+
7+
def on_start(self):
8+
self.client.get("/")
9+
10+
@task(3)
11+
def view_items(self):
12+
for item_id in range(1, 10):
13+
self.client.get(f"/owners/{item_id}", name="/owners")
14+
time.sleep(1)

0 commit comments

Comments
 (0)