From fa996afb2f81333288eb4dc97f37ac61821204f4 Mon Sep 17 00:00:00 2001 From: Nemanja Mikic Date: Wed, 11 Dec 2024 10:18:38 +0100 Subject: [PATCH] Remove http client registry from metrics (#1037) --- .../OracleCloudMeterRegistryFactory.java | 5 ++- .../AbstractOracleCloudMeterRegistry.java | 19 ---------- .../micrometer/OracleCloudMeterRegistry.java | 36 ------------------- .../OracleCloudRawMeterRegistry.java | 18 +++------- .../OracleCloudMeterRawRegistrySpec.groovy | 3 +- 5 files changed, 7 insertions(+), 74 deletions(-) diff --git a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/OracleCloudMeterRegistryFactory.java b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/OracleCloudMeterRegistryFactory.java index 25cbe2e32..3710de45e 100644 --- a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/OracleCloudMeterRegistryFactory.java +++ b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/OracleCloudMeterRegistryFactory.java @@ -22,7 +22,6 @@ import io.micronaut.context.annotation.Factory; import io.micronaut.context.annotation.Requires; import io.micronaut.core.util.StringUtils; -import io.micronaut.http.client.HttpClientRegistry; import io.micronaut.oraclecloud.core.TenancyIdProvider; import io.micronaut.oraclecloud.monitoring.micrometer.OracleCloudConfig; import io.micronaut.oraclecloud.monitoring.micrometer.OracleCloudMeterRegistry; @@ -123,7 +122,7 @@ OracleCloudMeterRegistry oracleCloudMeterRegistry(OracleCloudConfig oracleCloudC @Bean(preDestroy = "close") @Requires(property = MeterRegistryFactory.MICRONAUT_METRICS_ENABLED, notEquals = StringUtils.FALSE, defaultValue = StringUtils.TRUE) @Requires(property = OracleCloudMeterRegistryFactory.ORACLECLOUD_RAW_METRICS_ENABLED, notEquals = StringUtils.FALSE, defaultValue = StringUtils.FALSE) - OracleCloudRawMeterRegistry oracleCloudRawMeterRegistry(HttpClientRegistry httpClientRegistry, OracleCloudConfig oracleCloudConfig, Provider monitoringIngestionClientProvider) { - return new OracleCloudRawMeterRegistry(httpClientRegistry, oracleCloudConfig, Clock.SYSTEM, monitoringIngestionClientProvider); + OracleCloudRawMeterRegistry oracleCloudRawMeterRegistry(OracleCloudConfig oracleCloudConfig, Provider monitoringIngestionClientProvider) { + return new OracleCloudRawMeterRegistry(oracleCloudConfig, Clock.SYSTEM, monitoringIngestionClientProvider); } } diff --git a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/AbstractOracleCloudMeterRegistry.java b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/AbstractOracleCloudMeterRegistry.java index acc997416..4d9f28a3f 100644 --- a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/AbstractOracleCloudMeterRegistry.java +++ b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/AbstractOracleCloudMeterRegistry.java @@ -25,7 +25,6 @@ import io.micrometer.core.instrument.step.StepMeterRegistry; import io.micrometer.core.lang.Nullable; import io.micrometer.common.util.internal.logging.WarnThenDebugLogger; -import io.micronaut.http.client.HttpClientRegistry; import io.micronaut.oraclecloud.monitoring.MonitoringIngestionClient; import jakarta.inject.Provider; import org.slf4j.Logger; @@ -56,24 +55,6 @@ protected AbstractOracleCloudMeterRegistry(OracleCloudConfig oracleCloudConfig, start(threadFactory); } - /** - * - * @param httpClientRegistry Http Client Registry - * @param oracleCloudConfig Oracle Cloud Config - * @param clock Clock - * @param monitoringIngestionClientProvider Monitoring Ingestion Client Provider - * @param threadFactory Thread Factory - * @deprecated Use {@link AbstractOracleCloudMeterRegistry(OracleCloudConfig, Clock, Provider, ThreadFactory)} instead. - */ - @Deprecated(forRemoval = true, since = "4.3.0") - protected AbstractOracleCloudMeterRegistry(HttpClientRegistry httpClientRegistry, - OracleCloudConfig oracleCloudConfig, - Clock clock, - Provider monitoringIngestionClientProvider, - ThreadFactory threadFactory) { - this(oracleCloudConfig, clock, monitoringIngestionClientProvider, threadFactory); - } - @Override protected TimeUnit getBaseTimeUnit() { return TimeUnit.MILLISECONDS; diff --git a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRegistry.java b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRegistry.java index f298452c3..96063e886 100644 --- a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRegistry.java +++ b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRegistry.java @@ -30,7 +30,6 @@ import io.micrometer.core.instrument.step.StepMeterRegistry; import io.micrometer.core.instrument.util.NamedThreadFactory; import io.micrometer.core.lang.Nullable; -import io.micronaut.http.client.HttpClientRegistry; import io.micronaut.oraclecloud.monitoring.MonitoringIngestionClient; import jakarta.inject.Provider; @@ -38,7 +37,6 @@ import java.util.Date; import java.util.List; import java.util.Objects; -import java.util.concurrent.ThreadFactory; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -65,40 +63,6 @@ public OracleCloudMeterRegistry( super(oracleCloudConfig, clock, monitoringIngestionClientProvider, new NamedThreadFactory("oraclecloud-metrics-publisher")); } - /** - * - * @param httpClientRegistry Http Client Registry - * @param oracleCloudConfig Oracle Cloud Config - * @param clock Clock - * @param monitoringIngestionClientProvider Monitoring Ingestion Client Provider - * @deprecated Use {@link OracleCloudMeterRegistry(OracleCloudConfig, Clock, Provider, ThreadFactory)} instead. - */ - @Deprecated(forRemoval = true, since = "4.3.0") - public OracleCloudMeterRegistry(HttpClientRegistry httpClientRegistry, - OracleCloudConfig oracleCloudConfig, - Clock clock, - Provider monitoringIngestionClientProvider) { - this(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, new NamedThreadFactory("oraclecloud-metrics-publisher")); - } - - /** - * - * @param httpClientRegistry Http Client Registry - * @param oracleCloudConfig Oracle Cloud Config - * @param clock Clock - * @param monitoringIngestionClientProvider Monitoring Ingestion Client Provider - * @param threadFactory Thread Factory - * @deprecated Use {@link OracleCloudMeterRegistry(OracleCloudConfig, Clock, Provider, ThreadFactory)} instead. - */ - @Deprecated(forRemoval = true, since = "4.3.0") - public OracleCloudMeterRegistry(HttpClientRegistry httpClientRegistry, - OracleCloudConfig oracleCloudConfig, - Clock clock, - Provider monitoringIngestionClientProvider, - ThreadFactory threadFactory) { - super(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, threadFactory); - } - /** * @return list of all {@link Meter} data transformed into {@link MetricDataDetails} */ diff --git a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudRawMeterRegistry.java b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudRawMeterRegistry.java index e92cb1fdf..3d78de9cf 100644 --- a/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudRawMeterRegistry.java +++ b/oraclecloud-micrometer/src/main/java/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudRawMeterRegistry.java @@ -33,7 +33,6 @@ import io.micrometer.core.instrument.step.StepMeterRegistry; import io.micrometer.core.instrument.util.NamedThreadFactory; import io.micrometer.core.lang.Nullable; -import io.micronaut.http.client.HttpClientRegistry; import io.micronaut.oraclecloud.monitoring.MonitoringIngestionClient; import io.micronaut.oraclecloud.monitoring.primitives.OracleCloudDatapointProducer; import io.micronaut.oraclecloud.monitoring.primitives.OracleCloudCounter; @@ -47,7 +46,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.concurrent.ThreadFactory; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -62,18 +60,10 @@ public class OracleCloudRawMeterRegistry extends AbstractOracleCloudMeterRegistr private final Logger logger = LoggerFactory.getLogger(OracleCloudRawMeterRegistry.class); - public OracleCloudRawMeterRegistry(HttpClientRegistry httpClientRegistry, OracleCloudConfig oracleCloudConfig, - Clock clock, - Provider monitoringIngestionClientProvider - ) { - this(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, new NamedThreadFactory("oraclecloud-metrics-publisher")); - } - - public OracleCloudRawMeterRegistry(HttpClientRegistry httpClientRegistry, + public OracleCloudRawMeterRegistry( OracleCloudConfig oracleCloudConfig, - Clock clock, Provider monitoringIngestionClientProvider, - ThreadFactory threadFactory) { - super(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, threadFactory); + Clock clock, Provider monitoringIngestionClientProvider) { + super(oracleCloudConfig, clock, monitoringIngestionClientProvider, new NamedThreadFactory("oraclecloud-metrics-publisher")); } @@ -222,7 +212,7 @@ Stream trackRawData(Meter meter) { if (meter instanceof OracleCloudDatapointProducer oracleCloudDatapointProducer) { return Stream.of(metricDataDetails(meter.getId(), null, oracleCloudDatapointProducer.getDatapoints())); } - logger.error("Metrics name: %s. Haven't publish metrics for class: %s".formatted(meter.getId().toString(), meter.getClass())); + logger.error("Metrics name: {}. Haven't publish metrics for class: {}",meter.getId(), meter.getClass()); return Stream.empty(); } diff --git a/oraclecloud-micrometer/src/test/groovy/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRawRegistrySpec.groovy b/oraclecloud-micrometer/src/test/groovy/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRawRegistrySpec.groovy index 2ebe611f4..04931449e 100644 --- a/oraclecloud-micrometer/src/test/groovy/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRawRegistrySpec.groovy +++ b/oraclecloud-micrometer/src/test/groovy/io/micronaut/oraclecloud/monitoring/micrometer/OracleCloudMeterRawRegistrySpec.groovy @@ -2,7 +2,6 @@ package io.micronaut.oraclecloud.monitoring.micrometer import com.oracle.bmc.monitoring.model.Datapoint import io.micrometer.core.instrument.* -import io.micronaut.http.client.HttpClientRegistry import io.micronaut.oraclecloud.monitoring.MonitoringIngestionClient import jakarta.inject.Provider import spock.lang.AutoCleanup @@ -46,7 +45,7 @@ class OracleCloudMeterRawRegistrySpec extends Specification { @AutoCleanup @Shared - private OracleCloudRawMeterRegistry cloudMeterRegistry = new OracleCloudRawMeterRegistry(Mock(HttpClientRegistry.class), oracleCloudConfig, mockClock, new Provider() { + private OracleCloudRawMeterRegistry cloudMeterRegistry = new OracleCloudRawMeterRegistry(oracleCloudConfig, mockClock, new Provider() { @Override MonitoringIngestionClient get() { monitoringClient