From 5010e2dce9e32e60dd72c187d45d84c017793f62 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 10 Jan 2025 16:52:44 +0900 Subject: [PATCH] Polish (#5759) --- .../core/aop/CountedAspectTest.java | 14 +++++----- .../micrometer/core/aop/TimedAspectTest.java | 26 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/micrometer-core/src/test/java/io/micrometer/core/aop/CountedAspectTest.java b/micrometer-core/src/test/java/io/micrometer/core/aop/CountedAspectTest.java index dddb4195f7..47807862ef 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/aop/CountedAspectTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/aop/CountedAspectTest.java @@ -60,7 +60,7 @@ void countedWithSuccessfulMetrics() { Counter counter = meterRegistry.get("metric.success") .tag("method", "succeedWithMetrics") - .tag("class", getClass().getName() + "$CountedService") + .tag("class", CountedService.class.getName()) .tag("extra", "tag") .tag("result", "success") .counter(); @@ -89,7 +89,7 @@ void countedWithFailure() { Counter counter = meterRegistry.get("metric.failing") .tag("method", "fail") - .tag("class", getClass().getName() + "$CountedService") + .tag("class", CountedService.class.getName()) .tag("exception", "RuntimeException") .tag("result", "failure") .counter(); @@ -129,7 +129,7 @@ void countedWithSuccessfulMetricsWhenCompleted() { assertThat(meterRegistry.find("metric.success") .tag("method", "succeedWithMetrics") - .tag("class", getClass().getName() + "$AsyncCountedService") + .tag("class", AsyncCountedService.class.getName()) .tag("extra", "tag") .tag("exception", "none") .tag("result", "success") @@ -140,7 +140,7 @@ void countedWithSuccessfulMetricsWhenCompleted() { Counter counterAfterCompletion = meterRegistry.get("metric.success") .tag("method", "succeedWithMetrics") - .tag("class", getClass().getName() + "$AsyncCountedService") + .tag("class", AsyncCountedService.class.getName()) .tag("extra", "tag") .tag("exception", "none") .tag("result", "success") @@ -157,7 +157,7 @@ void countedWithFailureWhenCompleted() { assertThat(meterRegistry.find("metric.failing") .tag("method", "fail") - .tag("class", getClass().getName() + "$AsyncCountedService") + .tag("class", AsyncCountedService.class.getName()) .tag("exception", "RuntimeException") .tag("result", "failure") .counter()).isNull(); @@ -167,7 +167,7 @@ void countedWithFailureWhenCompleted() { Counter counter = meterRegistry.get("metric.failing") .tag("method", "fail") - .tag("class", getClass().getName() + "$AsyncCountedService") + .tag("class", AsyncCountedService.class.getName()) .tag("exception", "RuntimeException") .tag("result", "failure") .counter(); @@ -218,7 +218,7 @@ void countedWithSuccessfulMetricsWhenReturnsCompletionStageNull() { assertThat(meterRegistry.get("metric.success") .tag("method", "successButNull") - .tag("class", getClass().getName() + "$AsyncCountedService") + .tag("class", AsyncCountedService.class.getName()) .tag("extra", "tag") .tag("exception", "none") .tag("result", "success") diff --git a/micrometer-core/src/test/java/io/micrometer/core/aop/TimedAspectTest.java b/micrometer-core/src/test/java/io/micrometer/core/aop/TimedAspectTest.java index 4920d429e5..6980c2148a 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/aop/TimedAspectTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/aop/TimedAspectTest.java @@ -55,7 +55,7 @@ void timeMethod() { service.call(); assertThat(registry.get("call") - .tag("class", getClass().getName() + "$TimedService") + .tag("class", TimedService.class.getName()) .tag("method", "call") .tag("extra", "tag") .timer() @@ -88,7 +88,7 @@ void timeMethodWithLongTaskTimer() { service.longCall(); assertThat(registry.get("longCall") - .tag("class", getClass().getName() + "$TimedService") + .tag("class", TimedService.class.getName()) .tag("method", "longCall") .tag("extra", "tag") .longTaskTimers()).hasSize(1); @@ -136,7 +136,7 @@ void timeMethodWithError() { assertThatThrownBy(service::callRaisingError).isInstanceOf(TestError.class); assertThat(registry.get("callRaisingError") - .tag("class", getClass().getName() + "$TimedService") + .tag("class", TimedService.class.getName()) .tag("method", "callRaisingError") .tag("extra", "tag") .tag("exception", "TestError") @@ -158,7 +158,7 @@ void timeMethodWithErrorAndLongTaskTimer() { assertThatThrownBy(service::longCallRaisingError).isInstanceOf(TestError.class); assertThat(registry.get("longCallRaisingError") - .tag("class", getClass().getName() + "$TimedService") + .tag("class", TimedService.class.getName()) .tag("method", "longCallRaisingError") .tag("extra", "tag") .longTaskTimer() @@ -183,7 +183,7 @@ void timeMethodWhenCompleted() { completableFuture.join(); assertThat(registry.get("call") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "call") .tag("extra", "tag") .tag("exception", "none") @@ -209,7 +209,7 @@ void timeMethodWhenCompletedExceptionally() { assertThatThrownBy(completableFuture::join).isInstanceOf(CompletionException.class); assertThat(registry.get("call") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "call") .tag("extra", "tag") .tag("exception", "IllegalStateException") @@ -232,7 +232,7 @@ void timeMethodWhenReturnCompletionStageNull() { assertThat(registry.getMeters()).isNotEmpty(); assertThat(registry.get("callNull") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "callNull") .tag("extra", "tag") .tag("exception", "none") @@ -253,7 +253,7 @@ void timeMethodWithLongTaskTimerWhenCompleted() { CompletableFuture completableFuture = service.longCall(guardedResult); assertThat(registry.find("longCall") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "longCall") .tag("extra", "tag") .longTaskTimer() @@ -263,7 +263,7 @@ void timeMethodWithLongTaskTimerWhenCompleted() { completableFuture.join(); assertThat(registry.get("longCall") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "longCall") .tag("extra", "tag") .longTaskTimer() @@ -283,7 +283,7 @@ void timeMethodWithLongTaskTimerWhenCompletedExceptionally() { CompletableFuture completableFuture = service.longCall(guardedResult); assertThat(registry.find("longCall") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "longCall") .tag("extra", "tag") .longTaskTimer() @@ -293,7 +293,7 @@ void timeMethodWithLongTaskTimerWhenCompletedExceptionally() { assertThatThrownBy(completableFuture::join).isInstanceOf(CompletionException.class); assertThat(registry.get("longCall") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "longCall") .tag("extra", "tag") .longTaskTimer() @@ -313,13 +313,13 @@ void timeMethodWithLongTaskTimerWhenReturnCompletionStageNull() { assertThat(completableFuture).isNull(); assertThat(registry.get("longCallNull") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "longCallNull") .tag("extra", "tag") .longTaskTimers()).hasSize(1); assertThat(registry.find("longCallNull") - .tag("class", getClass().getName() + "$AsyncTimedService") + .tag("class", AsyncTimedService.class.getName()) .tag("method", "longCallNull") .tag("extra", "tag") .longTaskTimer()