Skip to content

Commit

Permalink
helidon metrics to oci integration (#5945)
Browse files Browse the repository at this point in the history
* Add Helidon Metrics integration with OCI

The change includes the following:
1. Port of v3 PR #5829 that includes additional changes and fixes.
2. Changes related to OciMetricsSupport use of Nima instead of SE Webserver dependency.
3. Fix pipeline error due to javadoc link that cannot be referenced
  • Loading branch information
klustria authored Jan 24, 2023
1 parent 895a932 commit 14e28ee
Show file tree
Hide file tree
Showing 17 changed files with 2,025 additions and 1 deletion.
10 changes: 10 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,16 @@
<artifactId>helidon-integrations-oci-sdk-cdi</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.metrics</groupId>
<artifactId>helidon-integrations-oci-metrics</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.oci.metrics</groupId>
<artifactId>helidon-integrations-oci-metrics-cdi</artifactId>
<version>${helidon.version}</version>
</dependency>
<dependency>
<groupId>io.helidon.integrations.vault</groupId>
<artifactId>helidon-integrations-vault</artifactId>
Expand Down
57 changes: 57 additions & 0 deletions integrations/oci/metrics/cdi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021, 2023 Oracle and/or its affiliates.
Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.integrations.oci.metrics</groupId>
<artifactId>helidon-integrations-oci-metrics-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>helidon-integrations-oci-metrics-cdi</artifactId>
<name>Helidon Integrations OCI Metrics CDI</name>
<description>Helidon Metrics to OCI via CDI</description>

<dependencies>
<dependency>
<groupId>io.helidon.integrations.oci.metrics</groupId>
<artifactId>helidon-integrations-oci-metrics</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.server</groupId>
<artifactId>helidon-microprofile-server</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
*
* Licensed 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 io.helidon.integrations.oci.metrics.cdi;

import io.helidon.config.Config;
import io.helidon.integrations.oci.metrics.OciMetricsSupport;
import io.helidon.microprofile.server.RoutingBuilders;

import com.oracle.bmc.monitoring.Monitoring;
import jakarta.annotation.Priority;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Singleton;

import static jakarta.interceptor.Interceptor.Priority.LIBRARY_BEFORE;

/**
* OCI metrics integration CDI extension.
*/

// This bean is added to handle injection on the ObserverMethod as it does not work on an Extension class.
@Singleton
public class OciMetricsBean {

// Make Priority higher than MetricsCdiExtension so this will only start after MetricsCdiExtension has completed.
void registerOciMetrics(@Observes @Priority(LIBRARY_BEFORE + 20) @Initialized(ApplicationScoped.class) Object ignore,
Config config, Monitoring monitoringClient) {
Config helidonConfig = config.get("ocimetrics");
if (helidonConfig.exists()) {
OciMetricsSupport.Builder builder = OciMetricsSupport.builder()
.config(helidonConfig)
.monitoringClient(monitoringClient);

RoutingBuilders.create(helidonConfig)
.routingBuilder()
.register(builder.build());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed 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 io.helidon.integrations.oci.metrics.cdi;

import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
import jakarta.enterprise.inject.spi.Extension;

/**
* OCI metrics integration CDI extension.
*/
public class OciMetricsCdiExtension implements Extension {

// A new bean is added to handle the Observer Method as injection does not work here
void addOciMetricsBean(@Observes BeforeBeanDiscovery event) {
event.addAnnotatedType(OciMetricsBean.class, OciMetricsBean.class.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed 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.
*/

/**
* Integrating with OCI Metrics Using CDI.
*/
package io.helidon.integrations.oci.metrics.cdi;
34 changes: 34 additions & 0 deletions integrations/oci/metrics/cdi/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed 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.
*/

/**
* Integrating with OCI Metrics Using CDI.
*/
module io.helidon.integrations.oci.metrics.cdi {
requires io.helidon.config.mp;
requires io.helidon.integrations.oci.metrics;
requires io.helidon.microprofile.config;
requires io.helidon.microprofile.server;

requires oci.java.sdk.monitoring;

requires jakarta.interceptor.api;
provides jakarta.enterprise.inject.spi.Extension with io.helidon.integrations.oci.metrics.cdi.OciMetricsCdiExtension;

opens io.helidon.integrations.oci.metrics.cdi to weld.core.impl, io.helidon.microprofile.cdi;

exports io.helidon.integrations.oci.metrics.cdi;
}
Loading

0 comments on commit 14e28ee

Please sign in to comment.