diff --git a/benchmarks/benchmarks-core/src/jmh/java/io/micrometer/benchmark/core/GaugeBenchmark.java b/benchmarks/benchmarks-core/src/jmh/java/io/micrometer/benchmark/core/GaugeBenchmark.java index 6e794e4b3d..4098f7afe4 100644 --- a/benchmarks/benchmarks-core/src/jmh/java/io/micrometer/benchmark/core/GaugeBenchmark.java +++ b/benchmarks/benchmarks-core/src/jmh/java/io/micrometer/benchmark/core/GaugeBenchmark.java @@ -35,34 +35,29 @@ public class GaugeBenchmark { private MeterRegistry registry; - private AtomicInteger stateObject; - @Setup public void setup() { registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); - stateObject = registry.gauge("test.gauge", new AtomicInteger()); + registry.gauge("test.gauge", new AtomicInteger()); // emits warn because of double registration - stateObject = registry.gauge("test.gauge", new AtomicInteger()); + registry.gauge("test.gauge", new AtomicInteger()); // emits debug because of double registration and keeps emitting debug from now on - stateObject = registry.gauge("test.gauge", new AtomicInteger()); + registry.gauge("test.gauge", new AtomicInteger()); } @Benchmark public AtomicInteger baseline() { - stateObject = new AtomicInteger(); - return stateObject; + return new AtomicInteger(); } @Benchmark public AtomicInteger gaugeReRegistrationWithoutBuilder() { - stateObject = registry.gauge("test.gauge", new AtomicInteger()); - return stateObject; + return registry.gauge("test.gauge", new AtomicInteger()); } @Benchmark public Gauge gaugeReRegistrationWithBuilder() { - stateObject = new AtomicInteger(); - return Gauge.builder("test.gauge", stateObject, AtomicInteger::doubleValue).register(registry); + return Gauge.builder("test.gauge", new AtomicInteger(), AtomicInteger::doubleValue).register(registry); } public static void main(String[] args) throws RunnerException { diff --git a/build.gradle b/build.gradle index 9291d56b41..b450198bfd 100644 --- a/build.gradle +++ b/build.gradle @@ -433,7 +433,7 @@ nexusPublishing { } wrapper { - gradleVersion = '8.11.1' + gradleVersion = '8.12' } defaultTasks 'build' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e2847c8200..cea7a793a8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6d6b..f3b75f3b0d 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMetricConverter.java b/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMetricConverter.java index 93e2313a70..2c79d334fa 100644 --- a/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMetricConverter.java +++ b/implementations/micrometer-registry-otlp/src/main/java/io/micrometer/registry/otlp/OtlpMetricConverter.java @@ -57,6 +57,7 @@ class OtlpMetricConverter { private final long deltaTimeUnixNano; + @SuppressWarnings("deprecation") OtlpMetricConverter(Clock clock, Duration step, TimeUnit baseTimeUnit, AggregationTemporality aggregationTemporality, NamingConvention namingConvention) { this.clock = clock; diff --git a/implementations/micrometer-registry-otlp/src/test/java/io/micrometer/registry/otlp/OtlpMeterRegistryTest.java b/implementations/micrometer-registry-otlp/src/test/java/io/micrometer/registry/otlp/OtlpMeterRegistryTest.java index 9d033f7ed8..9ddd41918e 100644 --- a/implementations/micrometer-registry-otlp/src/test/java/io/micrometer/registry/otlp/OtlpMeterRegistryTest.java +++ b/implementations/micrometer-registry-otlp/src/test/java/io/micrometer/registry/otlp/OtlpMeterRegistryTest.java @@ -206,6 +206,7 @@ void distributionWithPercentileHistogramShouldWriteHistogramOrExponentialHistogr .isEqualTo(Metric.DataCase.EXPONENTIAL_HISTOGRAM.getNumber()); } + @SuppressWarnings("deprecation") @Test void multipleMetricsWithSameMetaDataShouldBeSingleMetric() { Tags firstTag = Tags.of("key", "first"); @@ -427,6 +428,7 @@ protected void stepOverNStep(int numStepsToSkip) { clock.addSeconds(otlpConfig().step().getSeconds() * numStepsToSkip); } + @SuppressWarnings("deprecation") protected void assertHistogram(Metric metric, long startTime, long endTime, String unit, long count, double sum, double max) { assertThat(metric.getHistogram().getAggregationTemporality()) @@ -452,6 +454,7 @@ protected void assertHistogram(Metric metric, long startTime, long endTime, Stri } } + @SuppressWarnings("deprecation") protected void assertSum(Metric metric, long startTime, long endTime, double expectedValue) { NumberDataPoint sumDataPoint = metric.getSum().getDataPoints(0); assertMetricMetadata(metric, Optional.empty()); diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcClientObservationConvention.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcClientObservationConvention.java index 7c192379a4..3e21bdeec7 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcClientObservationConvention.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcClientObservationConvention.java @@ -15,6 +15,7 @@ */ package io.micrometer.core.instrument.binder.grpc; +import io.micrometer.common.KeyValue; import io.micrometer.common.KeyValues; import io.micrometer.core.instrument.binder.grpc.GrpcObservationDocumentation.LowCardinalityKeyNames; @@ -27,6 +28,10 @@ */ public class DefaultGrpcClientObservationConvention implements GrpcClientObservationConvention { + private static final KeyValue STATUS_CODE_UNKNOWN = LowCardinalityKeyNames.STATUS_CODE.withValue(UNKNOWN); + + private static final KeyValue PEER_PORT_UNKNOWN = LowCardinalityKeyNames.PEER_PORT.withValue(UNKNOWN); + @Override public String getName() { return "grpc.client"; @@ -39,12 +44,12 @@ public String getContextualName(GrpcClientObservationContext context) { @Override public KeyValues getLowCardinalityKeyValues(GrpcClientObservationContext context) { - String statusCode = context.getStatusCode() != null ? context.getStatusCode().name() : UNKNOWN; - String peerPort = context.getPeerPort() != null ? context.getPeerPort().toString() : UNKNOWN; - return KeyValues.of(LowCardinalityKeyNames.STATUS_CODE.withValue(statusCode), - LowCardinalityKeyNames.PEER_NAME.withValue(context.getPeerName()), - LowCardinalityKeyNames.PEER_PORT.withValue(peerPort), - LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()), + KeyValue statusCodeKeyValue = context.getStatusCode() != null + ? LowCardinalityKeyNames.STATUS_CODE.withValue(context.getStatusCode().name()) : STATUS_CODE_UNKNOWN; + KeyValue peerPortKeyValue = context.getPeerPort() != null + ? LowCardinalityKeyNames.PEER_PORT.withValue(context.getPeerPort().toString()) : PEER_PORT_UNKNOWN; + return KeyValues.of(statusCodeKeyValue, LowCardinalityKeyNames.PEER_NAME.withValue(context.getPeerName()), + peerPortKeyValue, LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()), LowCardinalityKeyNames.SERVICE.withValue(context.getServiceName()), LowCardinalityKeyNames.METHOD_TYPE.withValue(context.getMethodType().name())); } diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcServerObservationConvention.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcServerObservationConvention.java index 4beeca5730..b236b23ae2 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcServerObservationConvention.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/grpc/DefaultGrpcServerObservationConvention.java @@ -15,6 +15,7 @@ */ package io.micrometer.core.instrument.binder.grpc; +import io.micrometer.common.KeyValue; import io.micrometer.common.KeyValues; import io.micrometer.core.instrument.binder.grpc.GrpcObservationDocumentation.LowCardinalityKeyNames; @@ -27,6 +28,12 @@ */ public class DefaultGrpcServerObservationConvention implements GrpcServerObservationConvention { + private static final KeyValue STATUS_CODE_UNKNOWN = LowCardinalityKeyNames.STATUS_CODE.withValue(UNKNOWN); + + private static final KeyValue PEER_NAME_UNKNOWN = LowCardinalityKeyNames.PEER_NAME.withValue(UNKNOWN); + + private static final KeyValue PEER_PORT_UNKNOWN = LowCardinalityKeyNames.PEER_PORT.withValue(UNKNOWN); + @Override public String getName() { return "grpc.server"; @@ -39,12 +46,13 @@ public String getContextualName(GrpcServerObservationContext context) { @Override public KeyValues getLowCardinalityKeyValues(GrpcServerObservationContext context) { - String statusCode = context.getStatusCode() != null ? context.getStatusCode().name() : UNKNOWN; - String peerName = context.getPeerName() != null ? context.getPeerName() : UNKNOWN; - String peerPort = context.getPeerPort() != null ? context.getPeerPort().toString() : UNKNOWN; - return KeyValues.of(LowCardinalityKeyNames.STATUS_CODE.withValue(statusCode), - LowCardinalityKeyNames.PEER_NAME.withValue(peerName), - LowCardinalityKeyNames.PEER_PORT.withValue(peerPort), + KeyValue statusCodeKeyValue = context.getStatusCode() != null + ? LowCardinalityKeyNames.STATUS_CODE.withValue(context.getStatusCode().name()) : STATUS_CODE_UNKNOWN; + KeyValue peerNameKeyValue = context.getPeerName() != null + ? LowCardinalityKeyNames.PEER_NAME.withValue(context.getPeerName()) : PEER_NAME_UNKNOWN; + KeyValue peerPortKeyValue = context.getPeerPort() != null + ? LowCardinalityKeyNames.PEER_PORT.withValue(context.getPeerPort().toString()) : PEER_PORT_UNKNOWN; + return KeyValues.of(statusCodeKeyValue, peerNameKeyValue, peerPortKeyValue, LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()), LowCardinalityKeyNames.SERVICE.withValue(context.getServiceName()), LowCardinalityKeyNames.METHOD_TYPE.withValue(context.getMethodType().name()));