-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Drop support for "all" from management.metrics.distribution.sla #14684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
b68ab29
659ca93
40396b8
5ec9e20
48c99eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import java.util.Arrays; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.function.Function; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import io.micrometer.core.instrument.Meter; | ||
|
|
@@ -39,6 +40,7 @@ | |
| * @author Jon Schneider | ||
| * @author Phillip Webb | ||
| * @author Stephane Nicoll | ||
| * @author Artsiom Yudovin | ||
| * @since 2.0.0 | ||
| */ | ||
| public class PropertiesMeterFilter implements MeterFilter { | ||
|
|
@@ -66,7 +68,8 @@ private static MeterFilter createMapFilter(Map<String, String> tags) { | |
|
|
||
| @Override | ||
| public MeterFilterReply accept(Meter.Id id) { | ||
| boolean enabled = lookup(this.properties.getEnable(), id, true); | ||
| boolean enabled = lookup(this.properties.getEnable(), id, true, | ||
| (all) -> this.properties.getEnable().getOrDefault(all, null)); | ||
| return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY; | ||
| } | ||
|
|
||
|
|
@@ -79,11 +82,13 @@ public Id map(Id id) { | |
| public DistributionStatisticConfig configure(Meter.Id id, | ||
| DistributionStatisticConfig config) { | ||
| Distribution distribution = this.properties.getDistribution(); | ||
| return DistributionStatisticConfig.builder() | ||
| .percentilesHistogram( | ||
| lookup(distribution.getPercentilesHistogram(), id, null)) | ||
| .percentiles(lookup(distribution.getPercentiles(), id, null)) | ||
| .sla(convertSla(id.getType(), lookup(distribution.getSla(), id, null))) | ||
| return DistributionStatisticConfig.builder().percentilesHistogram(lookup( | ||
| distribution.getPercentilesHistogram(), id, null, | ||
| (all) -> distribution.getPercentilesHistogram().getOrDefault(all, null))) | ||
|
||
| .percentiles(lookup(distribution.getPercentiles(), id, null, | ||
| (all) -> distribution.getPercentiles().getOrDefault(all, null))) | ||
| .sla(convertSla(id.getType(), | ||
| lookup(distribution.getSla(), id, null, (all) -> null))) | ||
| .build().merge(config); | ||
| } | ||
|
|
||
|
|
@@ -97,7 +102,8 @@ private long[] convertSla(Meter.Type meterType, ServiceLevelAgreementBoundary[] | |
| return (converted.length != 0) ? converted : null; | ||
| } | ||
|
|
||
| private <T> T lookup(Map<String, T> values, Id id, T defaultValue) { | ||
| private <T> T lookup(Map<String, T> values, Id id, T defaultValue, | ||
|
||
| Function<String, T> all) { | ||
| if (values.isEmpty()) { | ||
| return defaultValue; | ||
| } | ||
|
|
@@ -110,7 +116,7 @@ private <T> T lookup(Map<String, T> values, Id id, T defaultValue) { | |
| int lastDot = name.lastIndexOf('.'); | ||
| name = (lastDot != -1) ? name.substring(0, lastDot) : ""; | ||
| } | ||
| return values.getOrDefault("all", defaultValue); | ||
| return all.apply("all"); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaults are out of sync here. One it
trueand the other isnull. This means we're missing a test as, with these changes, the following test will fail with aNullPointerException: