Skip to content

Commit

Permalink
feat(extension): onboard Observability Services
Browse files Browse the repository at this point in the history
Closes #6790
  • Loading branch information
squakez authored Dec 10, 2024
1 parent fb1b734 commit e5408e0
Show file tree
Hide file tree
Showing 26 changed files with 1,135 additions and 0 deletions.
13 changes: 13 additions & 0 deletions catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-observability-services</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-ognl</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/others/observability-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-observability-services
cqArtifactIdBase: observability-services
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 3.18.0
cqNativeSince: 3.18.0
cqCamelPartName: observability-services
cqCamelPartTitle: Observability Services
cqCamelPartDescription: Camel Observability Services
cqExtensionPageTitle: Observability Services
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
*** xref:reference/extensions/nitrite.adoc[Nitrite]
*** xref:reference/extensions/oaipmh.adoc[OAI-PMH]
*** xref:reference/extensions/ognl.adoc[OGNL]
*** xref:reference/extensions/observability-services.adoc[Observability Services]
*** xref:reference/extensions/olingo4.adoc[Olingo4]
*** xref:reference/extensions/openapi-java.adoc[OpenAPI Java]
*** xref:reference/extensions/opensearch.adoc[OpenSearch]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-observability-services"]
= Observability Services
:linkattrs:
:cq-artifact-id: camel-quarkus-observability-services
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Camel Observability Services
:cq-deprecated: false
:cq-jvm-since: 3.18.0
:cq-native-since: 3.18.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##3.18.0## [.badge-key]##Native since##[.badge-supported]##3.18.0##
endif::[]

Camel Observability Services

[id="extensions-observability-services-whats-inside"]
== What's inside

* xref:{cq-camel-components}:others:observability-services.adoc[Observability Services]

Please refer to the above link for usage and configuration details.

[id="extensions-observability-services-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-observability-services[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-observability-services</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-observability-services-usage"]
== Usage
This extension is used to provide a set of opinionated components and configuration which simplify operations such as observability on cloud environments. Although the component is mainly targeted for cloud, it can be used in any other environment, giving to the Camel application the capability to expose a set of observability features by default.

All you need to do is to add the dependency to the classpath. There's no need to add any further configuration. Each individual component will be configured using each own default settings except the endpoint which will be exposed in */observe/<service>* by default.

If you need to customize each of the different components provided within this service, then, you can specify in the *application.properties* each of the configuration as it would be done normally when you provide the individual component.

[id="extensions-observability-services-usage-components"]
== Components

The presence of this dependency will provide the following extensions:

* Camel Quarkus Microprofile
* Camel Quarkus Management
* Camel Quarkus Micrometer
* Camel Quarkus OpenTelemetry
* Quarkus Micrometer Registry Prometheus

[id="extensions-observability-services-usage-list-of-known-endpoints"]
=== List of known endpoints

The presence of this dependency will expose the following endpoints:

|====
|Endpoint | Description

| `/observe/health` | startup probe endpoint
| `/observe/health/live` | liveness probe endpoint
| `/observe/health/ready` | readiness probe endpoint
| `/observe/metrics` | metrics exposed as in Micrometer Prometheus Registry

|====

NOTE: you can configure the endpoints as you'd do normally within each extension configuration.

[id="extensions-observability-services-usage-opentelemetry-configuration"]
== OpenTelemetry configuration

The presence of this component will provide the required instrumentation to easily enable the collection of Opentelemetry metrics. The Camel Quarkus Opentelemetry extension instrument your application with a service which periodically pushes OTEL traces to the collector. This is disabled by default in order to prevent the application to push traces when no telemetry server is available.

In order to turn it on, you need to specify the following configuration explicitly:

```
quarkus.otel.sdk.disabled=false
```

Beside that, you can change any further parameter, like, for instance, the server where to push the traces (default, `http://localhost:4317`)

```
quarkus.otel.exporter.otlp.traces.endpoint=http://my-otel-collector.svc:4317
```

NOTE: Quarkus runtime defaults to gRPC protocol (port 4317).

[id="extensions-observability-services-usage-jmx-configuration"]
== JMX configuration

The presence of this component implies the presence of `camel-management` component. This is in charge to include information about Camel application status in JMX format.

NOTE: the presence of this components automatically enable the collection of the JMX metrics. This should be negligible from performance point of view, however, you may want to disable that running the application with `-Dorg.apache.camel.jmx.disabled=true` JVM option.


99 changes: 99 additions & 0 deletions extensions/observability-services/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-observability-services-parent</artifactId>
<version>3.18.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-observability-services-deployment</artifactId>
<name>Camel Quarkus :: Observability Services :: Deployment</name>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-observability-services</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-micrometer-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-health-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-opentelemetry-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-management-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security-deployment</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.observabilityservices.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;

class ObservabilityServicesProcessor {

private static final String FEATURE = "camel-observability-services";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.observabilityservices.deployment;

import io.quarkus.test.QuarkusUnitTest;
import jakarta.inject.Inject;
import org.apache.camel.CamelContext;
import org.apache.camel.health.HealthCheckRegistry;
import org.apache.camel.impl.health.ConsumersHealthCheckRepository;
import org.apache.camel.impl.health.ContextHealthCheck;
import org.apache.camel.impl.health.RoutesHealthCheckRepository;
import org.apache.camel.microprofile.health.CamelMicroProfileHealthCheckRegistry;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class MicroProfileHealthEnabledTest {

@RegisterExtension
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));

@Inject
CamelContext context;

@Test
public void healthCheckRegistryNotNull() {
HealthCheckRegistry registry = HealthCheckRegistry.get(context);
assertNotNull(registry);
assertTrue(registry instanceof CamelMicroProfileHealthCheckRegistry);
assertEquals("camel-microprofile-health", registry.getId());
}

@Test
public void contextHealthCheckNotNull() {
ContextHealthCheck contextHealthCheck = context.getRegistry().lookupByNameAndType("context", ContextHealthCheck.class);
assertNotNull(contextHealthCheck);
}

@Test
public void routesHealthCheckNotNull() {
RoutesHealthCheckRepository routesRepository = context.getRegistry().lookupByNameAndType("routes",
RoutesHealthCheckRepository.class);
assertNotNull(routesRepository);
}

@Test
public void consumersHealthCheckNotNull() {
ConsumersHealthCheckRepository consumersRepository = context.getRegistry().lookupByNameAndType("consumers",
ConsumersHealthCheckRepository.class);
assertNotNull(consumersRepository);
}
}
Loading

0 comments on commit e5408e0

Please sign in to comment.