From 91c7cceab35895c5e45bf6539e88b4042a0301ba Mon Sep 17 00:00:00 2001 From: James Netherton Date: Tue, 18 Feb 2025 11:34:16 +0000 Subject: [PATCH] Use observability-services extension in observability example project --- observability/README.adoc | 54 ++++++++----------- observability/pom.xml | 14 +---- .../acme/observability/ObservabilityTest.java | 6 +-- 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/observability/README.adoc b/observability/README.adoc index c536c8b4..1d009a30 100644 --- a/observability/README.adoc +++ b/observability/README.adoc @@ -19,20 +19,23 @@ workspace. Any modifications in your project will automatically take effect in t TIP: Please refer to the Development mode section of https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel Quarkus User guide] for more details. -=== Enabling metrics +=== Camel Observability Services -To enable observability features in Camel Quarkus, we need to add some additional dependencies to the project's pom.xml file. -The most important one for metrics is `camel-quarkus-micrometer`: +This project includes the `camel-quarkus-observability-services` extension. +This provides some opinionated observability configuration and simplifies your application. -[source, xml] ----- - - org.apache.camel.quarkus - camel-quarkus-micrometer - ----- +It comes with the following capabilities. + +* `camel-quarkus-microprofile-health` for health checks +* `camel-quarkus-management` for JMX monitoring and management +* `camel-quarkus-micromenter` for Micrometer metrics, together with support for exporting them in Prometheus format +* `camel-quarkus-opentelemetry` for tracing + +The `camel-quarkus-observability-services` extension exposes the above capabilities under a common HTTP endpoint context path of `/observe`. + +=== Metrics -After adding this dependency, you can benefit from both of the https://camel.apache.org/components/next/micrometer-component.html[Camel Micrometer] and https://quarkus.io/guides/micrometer[Quarkus Micrometer] worlds. +You can benefit from both of the https://camel.apache.org/components/next/micrometer-component.html[Camel Micrometer] and https://quarkus.io/guides/micrometer[Quarkus Micrometer] worlds. We are able to use multiple ways of creating meters for our custom metrics. First using Camel micrometer component (see link:src/main/java/org/acme/observability/Routes.java[Routes.java]): @@ -93,9 +96,9 @@ It can then be invoked from Camel via the bean EIP (see link:src/main/java/org/a It will increment the counter metric each time the Camel timer is fired. -=== Browsing metrics +=== Metrics endpoint -Metrics are exposed on an HTTP endpoint at `/q/metrics` on port `9000`. +Metrics are exposed on an HTTP endpoint at `/observe/metrics` on port `9000`. NOTE: Note we are using a different port (9000) for the management endpoint then our application (8080) is listening on. This is configured in `applcation.properties` via link:src/main/resources/application.properties#L22[`quarkus.management.enabled = true`]. See the https://quarkus.io/guides/management-interface-reference[Quarkus management interface guide] for more information. @@ -104,14 +107,14 @@ To view all Camel metrics do: [source,shell] ---- -$ curl -s localhost:9000/q/metrics +$ curl -s localhost:9000/observe/metrics ---- To view only our previously created metrics, use: [source,shell] ---- -$ curl -s localhost:9000/q/metrics | grep -i 'purpose="example"' +$ curl -s localhost:9000/observe/metrics | grep -i 'purpose="example"' ---- and you should see 3 lines of different metrics (with the same value, as they are all triggered by the timer). @@ -120,16 +123,16 @@ NOTE: Maybe you've noticed the Prometheus output format. If you would rather use === Health endpoint -Camel provides some out of the box liveness and readiness checks. To see this working, interrogate the `/q/health/live` and `/q/health/ready` endpoints on port `9000`: +Camel provides some out of the box liveness and readiness checks. To see this working, interrogate the `/observe/health/live` and `/observe/health/ready` endpoints on port `9000`: [source,shell] ---- -$ curl -s localhost:9000/q/health/live +$ curl -s localhost:9000/observe/health/live ---- [source,shell] ---- -$ curl -s localhost:9000/q/health/ready +$ curl -s localhost:9000/observe/health/ready ---- The JSON output will contain a checks for verifying whether the `CamelContext` and each individual route is in the 'Started' state. @@ -141,20 +144,9 @@ You can also directly leverage MicroProfile Health APIs to create checks. Class === Tracing -To be able to diagnose problems in Camel Quarkus applications, you can start tracing messages. -We will use OpenTelemetry standard suited for cloud environments. - -All you need is to add the `camel-quarkus-opentelemetry` dependency to your project `pom.xml`: - -[source, xml] ----- - - org.apache.camel.quarkus - camel-quarkus-opentelemetry - ----- +To be able to diagnose problems in Camel Quarkus applications, It's useful to instrument method calls, HTTP interactions etc with OpenTelemetry. -Then configure the OpenTelemetry exporter in `application.properties`: +Configure the OpenTelemetry exporter in `application.properties`: [source, text] ---- diff --git a/observability/pom.xml b/observability/pom.xml index 82f3e85f..aed4d65d 100644 --- a/observability/pom.xml +++ b/observability/pom.xml @@ -92,19 +92,7 @@ org.apache.camel.quarkus - camel-quarkus-microprofile-health - - - org.apache.camel.quarkus - camel-quarkus-micrometer - - - org.apache.camel.quarkus - camel-quarkus-opentelemetry - - - io.quarkus - quarkus-micrometer-registry-prometheus + camel-quarkus-observability-services io.quarkus diff --git a/observability/src/test/java/org/acme/observability/ObservabilityTest.java b/observability/src/test/java/org/acme/observability/ObservabilityTest.java index 8db44eab..e7edd940 100644 --- a/observability/src/test/java/org/acme/observability/ObservabilityTest.java +++ b/observability/src/test/java/org/acme/observability/ObservabilityTest.java @@ -45,7 +45,7 @@ public void greeting() { public void metrics() { // Verify Camel metrics are available String prometheusMetrics = RestAssured - .get(getManagementPrefix() + "/q/metrics") + .get(getManagementPrefix() + "/observe/metrics") .then() .statusCode(200) .extract() @@ -58,14 +58,14 @@ public void metrics() { @Test public void health() { // Verify liveness - RestAssured.get(getManagementPrefix() + "/q/health/live") + RestAssured.get(getManagementPrefix() + "/observe/health/live") .then() .statusCode(200) .body("status", is("UP"), "checks.findAll { it.name == 'custom-liveness-check' }.status", Matchers.contains("UP")); // Verify readiness - RestAssured.get(getManagementPrefix() + "/q/health/ready") + RestAssured.get(getManagementPrefix() + "/observe/health/ready") .then() .statusCode(200) .body("status", is("UP"),