Skip to content

Commit

Permalink
Remove http client registry from metrics (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
n0tl3ss authored Dec 11, 2024
1 parent 2759c12 commit fa996af
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<MonitoringIngestionClient> monitoringIngestionClientProvider) {
return new OracleCloudRawMeterRegistry(httpClientRegistry, oracleCloudConfig, Clock.SYSTEM, monitoringIngestionClientProvider);
OracleCloudRawMeterRegistry oracleCloudRawMeterRegistry(OracleCloudConfig oracleCloudConfig, Provider<MonitoringIngestionClient> monitoringIngestionClientProvider) {
return new OracleCloudRawMeterRegistry(oracleCloudConfig, Clock.SYSTEM, monitoringIngestionClientProvider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<MonitoringIngestionClient> monitoringIngestionClientProvider,
ThreadFactory threadFactory) {
this(oracleCloudConfig, clock, monitoringIngestionClientProvider, threadFactory);
}

@Override
protected TimeUnit getBaseTimeUnit() {
return TimeUnit.MILLISECONDS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
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;

import java.util.Collections;
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;

Expand All @@ -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<MonitoringIngestionClient> 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<MonitoringIngestionClient> monitoringIngestionClientProvider,
ThreadFactory threadFactory) {
super(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, threadFactory);
}

/**
* @return list of all {@link Meter} data transformed into {@link MetricDataDetails}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<MonitoringIngestionClient> monitoringIngestionClientProvider
) {
this(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, new NamedThreadFactory("oraclecloud-metrics-publisher"));
}

public OracleCloudRawMeterRegistry(HttpClientRegistry<?> httpClientRegistry,
public OracleCloudRawMeterRegistry(
OracleCloudConfig oracleCloudConfig,
Clock clock, Provider<MonitoringIngestionClient> monitoringIngestionClientProvider,
ThreadFactory threadFactory) {
super(httpClientRegistry, oracleCloudConfig, clock, monitoringIngestionClientProvider, threadFactory);
Clock clock, Provider<MonitoringIngestionClient> monitoringIngestionClientProvider) {
super(oracleCloudConfig, clock, monitoringIngestionClientProvider, new NamedThreadFactory("oraclecloud-metrics-publisher"));

}

Expand Down Expand Up @@ -222,7 +212,7 @@ Stream<MetricDataDetails> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +45,7 @@ class OracleCloudMeterRawRegistrySpec extends Specification {

@AutoCleanup
@Shared
private OracleCloudRawMeterRegistry cloudMeterRegistry = new OracleCloudRawMeterRegistry(Mock(HttpClientRegistry.class), oracleCloudConfig, mockClock, new Provider<MonitoringIngestionClient>() {
private OracleCloudRawMeterRegistry cloudMeterRegistry = new OracleCloudRawMeterRegistry(oracleCloudConfig, mockClock, new Provider<MonitoringIngestionClient>() {
@Override
MonitoringIngestionClient get() {
monitoringClient
Expand Down

0 comments on commit fa996af

Please sign in to comment.