Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use observability-services extension in observability example project #345

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 23 additions & 31 deletions observability/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-micrometer</artifactId>
</dependency>
----
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]):
Expand Down Expand Up @@ -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.
Expand All @@ -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).
Expand All @@ -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.
Expand All @@ -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]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-opentelemetry</artifactId>
</dependency>
----
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]
----
Expand Down
14 changes: 1 addition & 13 deletions observability/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-health</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-micrometer</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-opentelemetry</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
<artifactId>camel-quarkus-observability-services</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"),
Expand Down