diff --git a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsLoadBalancerFailTest.java b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsLoadBalancerFailTest.java index 0262201f5a416..099b98383964d 100644 --- a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsLoadBalancerFailTest.java +++ b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsLoadBalancerFailTest.java @@ -27,7 +27,7 @@ import io.quarkus.micrometer.test.Util; import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; -import io.smallrye.stork.api.observability.ObservationPoints; +import io.smallrye.stork.api.observability.StorkObservationPoints; @DisabledOnOs(OS.WINDOWS) public class StorkMetricsLoadBalancerFailTest { @@ -81,7 +81,7 @@ public void shouldGetStorkMetricsWhenServiceSelectorFails() { } private static void assertStorkMetrics() { - ObservationPoints.StorkResolutionEvent metrics = StorkObservationCollectorBean.STORK_METRICS + StorkObservationPoints metrics = StorkObservationCollectorBean.STORK_METRICS .get("pingpong-service" + StorkObservationCollectorBean.METRICS_SUFIX); Assertions.assertThat(metrics.getDiscoveredInstancesCount()).isEqualTo(1); Assertions.assertThat(metrics.getSelectedInstanceId()).isEqualTo(-1); diff --git a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsServiceDiscoveryFailTest.java b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsServiceDiscoveryFailTest.java index 8a3bcc483ab32..ade4d555fdb68 100644 --- a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsServiceDiscoveryFailTest.java +++ b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsServiceDiscoveryFailTest.java @@ -26,7 +26,7 @@ import io.quarkus.test.QuarkusUnitTest; import io.restassured.RestAssured; import io.smallrye.mutiny.Uni; -import io.smallrye.stork.api.observability.ObservationPoints; +import io.smallrye.stork.api.observability.StorkObservationPoints; public class StorkMetricsServiceDiscoveryFailTest { @@ -77,7 +77,7 @@ public void shouldGetStorkMetricsWhenServiceDiscoveryFails() { } private static void assertStorkMetrics() { - ObservationPoints.StorkResolutionEvent metrics = StorkObservationCollectorBean.STORK_METRICS + StorkObservationPoints metrics = StorkObservationCollectorBean.STORK_METRICS .get("pingpong-service" + StorkObservationCollectorBean.METRICS_SUFIX); Assertions.assertThat(metrics.getDiscoveredInstancesCount()).isNegative(); Assertions.assertThat(metrics.getSelectedInstanceId()).isEqualTo(-1); diff --git a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsTest.java b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsTest.java index 80eba2968436f..95ab0831a49e2 100644 --- a/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsTest.java +++ b/extensions/micrometer/deployment/src/test/java/io/quarkus/micrometer/deployment/binder/StorkMetricsTest.java @@ -2,7 +2,6 @@ package io.quarkus.micrometer.deployment.binder; import static io.restassured.RestAssured.when; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; import java.util.concurrent.TimeUnit; @@ -22,7 +21,7 @@ import io.quarkus.micrometer.test.PingPongResource; import io.quarkus.micrometer.test.Util; import io.quarkus.test.QuarkusUnitTest; -import io.smallrye.stork.api.observability.ObservationPoints; +import io.smallrye.stork.api.observability.StorkObservationPoints; public class StorkMetricsTest { @@ -79,7 +78,7 @@ public void assertStorkMetricsInMicrometerRegistry(String serviceName) { } public static void assertStorkMetrics(String serviceName) { - ObservationPoints.StorkResolutionEvent metrics = StorkObservationCollectorBean.STORK_METRICS + StorkObservationPoints metrics = StorkObservationCollectorBean.STORK_METRICS .get(serviceName + StorkObservationCollectorBean.METRICS_SUFIX); Assertions.assertThat(metrics.getDiscoveredInstancesCount()).isEqualTo(1); Assertions.assertThat(metrics.getSelectedInstanceId()).isNotNegative(); diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/stork/StorkObservationCollectorBean.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/stork/StorkObservationCollectorBean.java index 7f02ca81ad543..ac7145492ea3f 100644 --- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/stork/StorkObservationCollectorBean.java +++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/stork/StorkObservationCollectorBean.java @@ -17,27 +17,28 @@ import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.Timer; import io.smallrye.stork.api.observability.ObservationCollector; -import io.smallrye.stork.api.observability.ObservationPoints; +import io.smallrye.stork.api.observability.StorkEventHandler; +import io.smallrye.stork.api.observability.StorkObservationPoints; @ApplicationScoped @Typed(ObservationCollector.class) -public class StorkObservationCollectorBean implements ObservationCollector, ObservationCollector.EventCompletionHandler { +public class StorkObservationCollectorBean implements ObservationCollector, StorkEventHandler { public static final String METRICS_SUFIX = "-metrics"; final MeterRegistry registry = Metrics.globalRegistry; - public final static Map STORK_METRICS = new ConcurrentHashMap<>(); + public final static Map STORK_METRICS = new ConcurrentHashMap<>(); @Override - public ObservationPoints.StorkResolutionEvent create(String serviceName, String serviceDiscoveryType, + public StorkObservationPoints create(String serviceName, String serviceDiscoveryType, String serviceSelectionType) { return STORK_METRICS.computeIfAbsent(serviceName + METRICS_SUFIX, - key -> new ObservationPoints.StorkResolutionEvent(serviceName, serviceDiscoveryType, serviceSelectionType, + key -> new StorkObservationPoints(serviceName, serviceDiscoveryType, serviceSelectionType, this)); } @Override - public void complete(ObservationPoints.StorkResolutionEvent event) { + public void complete(StorkObservationPoints event) { Tags tags = Tags.of(Tag.of("service-name", event.getServiceName())); Counter instanceCounter = Counter.builder("stork.instances.count") @@ -83,7 +84,7 @@ public void complete(ObservationPoints.StorkResolutionEvent event) { overallTimer.record(event.getServiceSelectionDuration().getNano(), TimeUnit.NANOSECONDS); if (event.failure() != null) { - if (event.isServiceDiscoveryDone()) { + if (event.isServiceDiscoverySuccessful()) { serviceSelectionExceptions.add(event.failure()); } else {// SD failure serviceDiscoveryExceptions.add(event.failure());