-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helidon metrics to oci integration (#5945)
* 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
Showing
17 changed files
with
2,025 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
53 changes: 53 additions & 0 deletions
53
...oci/metrics/cdi/src/main/java/io/helidon/integrations/oci/metrics/cdi/OciMetricsBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ics/cdi/src/main/java/io/helidon/integrations/oci/metrics/cdi/OciMetricsCdiExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...s/oci/metrics/cdi/src/main/java/io/helidon/integrations/oci/metrics/cdi/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
34
integrations/oci/metrics/cdi/src/main/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.