From 201f054d3079a51ecbb617bbb9c8319aacdf7966 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 12 Sep 2023 03:19:47 +0900 Subject: [PATCH] Polish (#4077) --- .../main/java/io/micrometer/prometheus/PrometheusTimer.java | 2 +- .../core/instrument/binder/logging/LogbackMetrics.java | 2 +- .../distribution/TimeWindowFixedBoundaryHistogram.java | 3 ++- .../core/instrument/step/StepDistributionSummary.java | 4 ++-- .../java/io/micrometer/core/instrument/step/StepTimer.java | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/implementations/micrometer-registry-prometheus/src/main/java/io/micrometer/prometheus/PrometheusTimer.java b/implementations/micrometer-registry-prometheus/src/main/java/io/micrometer/prometheus/PrometheusTimer.java index af3f835172..56929da80d 100644 --- a/implementations/micrometer-registry-prometheus/src/main/java/io/micrometer/prometheus/PrometheusTimer.java +++ b/implementations/micrometer-registry-prometheus/src/main/java/io/micrometer/prometheus/PrometheusTimer.java @@ -94,7 +94,7 @@ protected void recordNonNegative(long amount, TimeUnit unit) { max.record(nanoAmount, TimeUnit.NANOSECONDS); if (histogram != null) { - histogram.recordLong(TimeUnit.NANOSECONDS.convert(amount, unit)); + histogram.recordLong(nanoAmount); } } diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/logging/LogbackMetrics.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/logging/LogbackMetrics.java index 341aad4d15..6c83c64f36 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/logging/LogbackMetrics.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/logging/LogbackMetrics.java @@ -206,7 +206,7 @@ public FilterReply decide(Marker marker, Logger logger, Level level, String form // and can return immediately and // avoid the relatively expensive ThreadLocal access below. See also logbacks // Logger.callTurboFilters(). - // Calling logger.isEnabledFor(level) might be sub-optimal since it cals this + // Calling logger.isEnabledFor(level) might be sub-optimal since it calls this // filter again. This behavior caused a StackOverflowError in the past. if (format == null || !level.isGreaterOrEqual(logger.getEffectiveLevel())) { return FilterReply.NEUTRAL; diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/distribution/TimeWindowFixedBoundaryHistogram.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/distribution/TimeWindowFixedBoundaryHistogram.java index 875dfe8d6f..2782d6f797 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/distribution/TimeWindowFixedBoundaryHistogram.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/distribution/TimeWindowFixedBoundaryHistogram.java @@ -122,9 +122,10 @@ void outputSummary(PrintStream printStream, double bucketScaling) { String bucketFormatString = "%14.1f %10d\n"; + FixedBoundaryHistogram currentHistogram = currentHistogram(); for (int i = 0; i < buckets.length; i++) { printStream.format(Locale.US, bucketFormatString, buckets[i] / bucketScaling, - currentHistogram().values.get(i)); + currentHistogram.values.get(i)); } printStream.write('\n'); diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepDistributionSummary.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepDistributionSummary.java index c679da9862..93fba91b20 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepDistributionSummary.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepDistributionSummary.java @@ -46,7 +46,7 @@ public class StepDistributionSummary extends AbstractDistributionSummary impleme * Create a new {@code StepDistributionSummary}. * @param id ID * @param clock clock - * @param distributionStatisticConfig distribution static configuration + * @param distributionStatisticConfig distribution statistic configuration * @param scale scale * @param stepMillis step in milliseconds * @param supportsAggregablePercentiles whether it supports aggregable percentiles @@ -60,7 +60,7 @@ public StepDistributionSummary(Id id, Clock clock, DistributionStatisticConfig d @Override protected void recordNonNegative(double amount) { - count.add(1); + count.add(1L); total.add(amount); max.record(amount); } diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepTimer.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepTimer.java index 11dffdd8dc..aeca5455db 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepTimer.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/step/StepTimer.java @@ -59,7 +59,7 @@ public StepTimer(final Id id, final Clock clock, final DistributionStatisticConf @Override protected void recordNonNegative(final long amount, final TimeUnit unit) { final long nanoAmount = (long) TimeUtils.convert(amount, unit, TimeUnit.NANOSECONDS); - count.add(1); + count.add(1L); total.add(nanoAmount); max.record(nanoAmount); }