diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index c87c892efb..cf2c086a06 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -10,4 +10,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/wrapper-validation-action@v2 diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/dropwizard/DropwizardMeterRegistry.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/dropwizard/DropwizardMeterRegistry.java index 3635763cb8..8fc5d62bcf 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/dropwizard/DropwizardMeterRegistry.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/dropwizard/DropwizardMeterRegistry.java @@ -31,7 +31,6 @@ import java.lang.ref.WeakReference; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.ToDoubleFunction; import java.util.function.ToLongFunction; @@ -53,8 +52,6 @@ public abstract class DropwizardMeterRegistry extends MeterRegistry { private final DropwizardConfig dropwizardConfig; - private final AtomicBoolean warnLogged = new AtomicBoolean(); - public DropwizardMeterRegistry(DropwizardConfig config, MetricRegistry registry, HierarchicalNameMapper nameMapper, Clock clock) { super(clock); diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsConnectionPoolListenerTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsConnectionPoolListenerTest.java index 7e0757dd27..719ca80981 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsConnectionPoolListenerTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/binder/mongodb/MongoMetricsConnectionPoolListenerTest.java @@ -114,6 +114,7 @@ public void clusterOpening(ClusterOpeningEvent event) { } @Issue("#2384") + @Test void whenConnectionCheckedInAfterPoolClose_thenNoExceptionThrown() { ServerId serverId = new ServerId(new ClusterId(), new ServerAddress(host, port)); ConnectionId connectionId = new ConnectionId(serverId); diff --git a/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/MultiGaugeSample.java b/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/MultiGaugeSample.java new file mode 100644 index 0000000000..40a640ae48 --- /dev/null +++ b/samples/micrometer-samples-core/src/main/java/io/micrometer/core/samples/MultiGaugeSample.java @@ -0,0 +1,87 @@ +/* + * Copyright 2024 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.core.samples; + +import io.micrometer.core.instrument.MultiGauge; +import io.micrometer.core.instrument.MultiGauge.Row; +import io.micrometer.core.instrument.Tags; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class MultiGaugeSample { + + public static void main(String[] args) { + // MeterRegistry registry = SampleConfig.myMonitoringSystem(); + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + + MultiGauge temperatures = MultiGauge.builder("temperatures") + .tag("home", "little-house") + .description("The temperature by room") + .baseUnit("celsius") + .register(registry); + + // @formatter:off + for (int i = 0; i < 3; i++) { + temperatures.register( + fetchTemperatures().stream() + .map(record -> Row.of(Tags.of("room", record.getRoom().name()), record.getTemperature())) + .collect(Collectors.toList()), + true // whether to overwrite the previous value or only record it once + ); + + System.out.println("---"); + System.out.println(registry.getMetersAsString()); + } + // @formatter:on + } + + private static List fetchTemperatures() { + return Arrays.stream(Room.values()) + .map(room -> new TemperatureRecord(room, Math.random() * 3 + 20)) + .collect(Collectors.toList()); + } + + private enum Room { + + LIVING_ROOM, BEDROOM, KITCHEN + + } + + private static class TemperatureRecord { + + private final Room room; + + private final double temperature; + + private TemperatureRecord(Room room, double temperature) { + this.room = room; + this.temperature = temperature; + } + + public Room getRoom() { + return room; + } + + public double getTemperature() { + return temperature; + } + + } + +}