You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.adoc
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ readme's instructions.
27
27
=== Examples
28
28
29
29
// examples: START
30
-
Number of Examples: 66 (0 deprecated)
30
+
Number of Examples: 67 (0 deprecated)
31
31
32
32
[width="100%",cols="4,2,4",options="header"]
33
33
|===
@@ -168,6 +168,8 @@ Number of Examples: 66 (0 deprecated)
168
168
| link:salesforce/README.adoc[Salesforce] (salesforce) | SaaS | How to work with Salesforce contacts using REST endpoints and Streaming API
169
169
170
170
| link:twitter-salesforce/README.adoc[Twitter Salesforce] (twitter-salesforce) | SaaS | Twitter mentions is created as contacts in Salesforce
171
+
172
+
| link:observability-services/README.adoc[Observability Services] | Management and Monitoring | An example showing how to use Camel with Observability Services
== Spring Boot Example with Camel Observability Services
2
+
3
+
=== Introduction
4
+
5
+
This example illustrates how to use https://projects.spring.io/spring-boot/[Spring Boot] with http://camel.apache.org[Camel] to demonstrate observability capabilities. It implements a REST service that generates random numbers with variable response times, showcasing distributed tracing, metrics collection, and monitoring through OpenTelemetry.
6
+
7
+
The project uses `camel-observability-services-starter` component for automatic instrumentation, `camel-platform-http-starter` for REST endpoints, and integrates with OpenTelemetry Java agent for comprehensive observability.
8
+
9
+
For additional information there is https://camel.apache.org/blog/2025/03/camel-observability[blog post]
10
+
11
+
=== Observability Stack
12
+
13
+
To run the complete observability stack with Jaeger and Prometheus:
14
+
15
+
[source,bash]
16
+
----
17
+
docker-compose up
18
+
----
19
+
20
+
This will start:
21
+
22
+
- OpenTelemetry Collector (ports 4317/4318) - collects traces and metrics
- Prometheus (http://localhost:9090) - metrics collection and storage
25
+
26
+
The application, using agent, sends telemetry data to the OpenTelemetry Collector, which exports traces to Jaeger and metrics to Prometheus.
27
+
28
+
=== Run
29
+
30
+
You can run this example using:
31
+
32
+
[source,bash]
33
+
----
34
+
mvn spring-boot:run
35
+
----
36
+
37
+
After the Spring Boot application is started, you can execute the following HTTP requests:
38
+
39
+
[source,bash]
40
+
----
41
+
curl http://localhost:8080/api/random
42
+
----
43
+
44
+
The command will call the random number generator endpoint. Each call will:
45
+
- Generate a random number between 1-1000
46
+
- Simulate a random delay between 100-2000ms
47
+
- Return the number as response body
48
+
- Create traces and metrics for observability
49
+
50
+
You should see output similar to:
51
+
52
+
----
53
+
INFO 101511 --- [ task-1] generate-random-number : Generated random number: 742 with delay: 1250ms
54
+
----
55
+
56
+
=== Exposed Observability endpoints
57
+
58
+
The `camel-observability-services-starter` will configure the application and overrides the actuator setup so the health and metrics (in prometheus format) endpoints will be
59
+
60
+
```
61
+
http://localhost:9876/observe/health
62
+
63
+
http://localhost:9876/observe/metrics
64
+
```
65
+
66
+
even if in this example the metrics will be distributed using OpenTelemetry agent and not scraping the `/observe/metrics` endpoint
67
+
68
+
=== Testing Observability
69
+
70
+
1. **Generate some traffic:**
71
+
[source,bash]
72
+
----
73
+
for i in {1..10}; do curl http://localhost:8080/api/random; echo; sleep 1; done
74
+
----
75
+
76
+
2. **View traces in Jaeger:**
77
+
- Open http://localhost:16686
78
+
- Select service and search for traces
79
+
80
+
3. **View metrics in Prometheus:**
81
+
- Open http://localhost:9090
82
+
- Query metrics like `camel_route_exchange_completed_total`
83
+
84
+
85
+
The Spring Boot application can be stopped pressing `[CTRL] + [C]` in the shell.
86
+
87
+
=== Help and contributions
88
+
89
+
If you hit any problem using Camel or have some feedback, then please
90
+
https://camel.apache.org/community/support/[let us know].
0 commit comments