From 13f21f22e4201a808f5a2e35b6cd92a9c5ae260a Mon Sep 17 00:00:00 2001 From: Witalij Berdinskich Date: Tue, 21 Dec 2021 08:30:49 +0200 Subject: [PATCH] MeteredDecoder records timer once in happy path --- .../src/main/java/feign/micrometer/MeteredDecoder.java | 1 - .../java/feign/micrometer/AbstractMetricsTestBase.java | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java b/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java index c47e5baa9..8800a7e29 100644 --- a/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java +++ b/micrometer/src/main/java/feign/micrometer/MeteredDecoder.java @@ -62,7 +62,6 @@ public Object decode(Response response, Type type) try { decoded = decoder.decode(meteredResponse, type); timer = createTimer(response, type, null); - sample.stop(timer); } catch (IOException | RuntimeException e) { timer = createTimer(response, type, e); createExceptionCounter(response, type, e).count(); diff --git a/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java b/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java index 0b62f52c4..441a927f3 100644 --- a/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java +++ b/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java @@ -74,6 +74,13 @@ public final void addMetricsCapability() { .filter(this::doesMetricHasCounter) .forEach(metric -> assertEquals(1, getMetricCounter(metric))); + final Map decoderMetrics = getFeignMetrics().entrySet().stream() + .filter(entry -> isDecoderMetric(entry.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + decoderMetrics.values().stream() + .filter(this::doesMetricHasCounter) + .forEach(metric -> assertEquals(1, getMetricCounter(metric))); } protected abstract boolean doesMetricIncludeHost(METRIC_ID metricId);