Skip to content

Commit

Permalink
Merge branch '1.10.x' into 1.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Jan 30, 2024
2 parents f479c5e + 1672e0b commit 58aa718
Showing 4 changed files with 89 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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<TemperatureRecord> 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;
}

}

}

0 comments on commit 58aa718

Please sign in to comment.