mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-19 22:09:01 +00:00
Merge branch '3.5.x' into 4.0.x
Closes gh-48987
This commit is contained in:
+10
-15
@@ -20,7 +20,6 @@ import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.micrometer.core.instrument.Meter;
|
||||
import io.micrometer.core.instrument.Meter.Id;
|
||||
@@ -88,12 +87,9 @@ public class PropertiesMeterFilter implements MeterFilter {
|
||||
return DistributionStatisticConfig.builder()
|
||||
.percentilesHistogram(lookupWithFallbackToAll(distribution.getPercentilesHistogram(), id, null))
|
||||
.percentiles(lookupWithFallbackToAll(distribution.getPercentiles(), id, null))
|
||||
.serviceLevelObjectives(
|
||||
convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id, null)))
|
||||
.minimumExpectedValue(
|
||||
convertMeterValue(id.getType(), lookup(distribution.getMinimumExpectedValue(), id, null)))
|
||||
.maximumExpectedValue(
|
||||
convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id, null)))
|
||||
.serviceLevelObjectives(convertServiceLevelObjectives(id.getType(), lookup(distribution.getSlo(), id)))
|
||||
.minimumExpectedValue(convertMeterValue(id.getType(), lookup(distribution.getMinimumExpectedValue(), id)))
|
||||
.maximumExpectedValue(convertMeterValue(id.getType(), lookup(distribution.getMaximumExpectedValue(), id)))
|
||||
.expiry(lookupWithFallbackToAll(distribution.getExpiry(), id, null))
|
||||
.bufferLength(lookupWithFallbackToAll(distribution.getBufferLength(), id, null))
|
||||
.build()
|
||||
@@ -117,12 +113,11 @@ public class PropertiesMeterFilter implements MeterFilter {
|
||||
return (value != null) ? MeterValue.valueOf(value).getValue(meterType) : null;
|
||||
}
|
||||
|
||||
private <T> @Nullable T lookup(Map<String, T> values, Id id, @Nullable T defaultValue) {
|
||||
private <T> @Nullable T lookup(Map<String, T> values, Id id) {
|
||||
if (values.isEmpty()) {
|
||||
return defaultValue;
|
||||
return null;
|
||||
}
|
||||
Supplier<@Nullable T> getDefaultValue = () -> defaultValue;
|
||||
return doLookup(values, id, getDefaultValue);
|
||||
return doLookup(values, id);
|
||||
}
|
||||
|
||||
@Contract("_, _, !null -> !null")
|
||||
@@ -130,11 +125,11 @@ public class PropertiesMeterFilter implements MeterFilter {
|
||||
if (values.isEmpty()) {
|
||||
return defaultValue;
|
||||
}
|
||||
Supplier<@Nullable T> getAllOrDefaultValue = () -> values.getOrDefault("all", defaultValue);
|
||||
return doLookup(values, id, getAllOrDefaultValue);
|
||||
@Nullable T result = doLookup(values, id);
|
||||
return (result != null) ? result : values.getOrDefault("all", defaultValue);
|
||||
}
|
||||
|
||||
private <T> @Nullable T doLookup(Map<String, T> values, Id id, Supplier<@Nullable T> defaultValue) {
|
||||
private <T> @Nullable T doLookup(Map<String, T> values, Id id) {
|
||||
String name = id.getName();
|
||||
while (StringUtils.hasLength(name)) {
|
||||
T result = values.get(name);
|
||||
@@ -145,7 +140,7 @@ public class PropertiesMeterFilter implements MeterFilter {
|
||||
name = (lastDot != -1) ? name.substring(0, lastDot) : "";
|
||||
}
|
||||
|
||||
return defaultValue.get();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user