-
Notifications
You must be signed in to change notification settings - Fork 41.5k
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
Conversation
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.
Thanks for the PR, but the proposed changes are broader than we want. We only want to drop support for all
from configuring the SLA. It should still continue to work as it does today for the other properties.
@@ -115,14 +116,6 @@ public void acceptWhenHasHigherEnableTrueExactEnableFalseShouldReturnDeny() { | |||
.isEqualTo(MeterFilterReply.DENY); | |||
} | |||
|
|||
@Test | |||
public void acceptWhenHasAllEnableFalseShouldReturnDeny() { |
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.
This test should be kept and should continue to pass. We only want to drop support for all
when configuring the SLA. It should be kept for controlling which meters are enabled.
@@ -181,14 +174,6 @@ public void configureWhenHasHigherHistogramFalseAndLowerTrueShouldSetPercentiles | |||
DistributionStatisticConfig.DEFAULT).isPercentileHistogram()).isTrue(); | |||
} | |||
|
|||
@Test | |||
public void configureWhenAllHistogramTrueSetPercentilesHistogramToTrue() { |
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.
This test should be kept and should continue to pass.
@@ -217,15 +202,6 @@ public void configureWhenHasHigherPercentilesAndLowerShouldSetPercentilesToHighe | |||
3.5, 4); | |||
} | |||
|
|||
@Test | |||
public void configureWhenAllPercentilesSetShouldSetPercentilesToValue() { |
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.
This test should be kept and should continue to pass.
@wilkinsona, thank you for your comments. I have updated follow your advice. |
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.
Thanks for the updates but we're not quite there yet. I've left a few comments describing what I think needs to be changed. Can you please take a look?
@@ -97,7 +102,8 @@ public DistributionStatisticConfig configure(Meter.Id id, | |||
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, |
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.
This doesn't look quite right as defaultValue
is never used.
.sla(convertSla(id.getType(), lookup(distribution.getSla(), id, null))) | ||
return DistributionStatisticConfig.builder().percentilesHistogram(lookup( | ||
distribution.getPercentilesHistogram(), id, null, | ||
(all) -> distribution.getPercentilesHistogram().getOrDefault(all, null))) |
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.
I'm not too keen on the repetition of distribution.getPercentilesHistogram()
.
I think it would be better to have a lookup
method and another method that's something like lookupWithFallbackToAll
. Both could delegate to another method to do the actual lookup and could then either just apply the default value, or could fall back to looking for all
and only then applying the default value if needed.
That would change this code to look something like this:
return DistributionStatisticConfig.builder()
.percentilesHistogram(lookupWithFallbackToAll(
distribution.getPercentilesHistogram(), id, null))
.percentiles(
lookupWithFallbackToAll(distribution.getPercentiles(), id, null))
.sla(convertSla(id.getType(), lookup(distribution.getSla(), id, null)))
.build().merge(config);
@@ -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)); |
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 true
and the other is null
. This means we're missing a test as, with these changes, the following test will fail with a NullPointerException
:
@Test
public void acceptWhenHasNoMatchingEnabledPropertyShouldReturnNeutral() {
PropertiesMeterFilter filter = new PropertiesMeterFilter(
createProperties("enable.something.else=false"));
assertThat(filter.accept(createMeterId("spring.boot")))
.isEqualTo(MeterFilterReply.NEUTRAL);
}
@wilkinsona, I took a look and added changes by your comments |
* gh-14684: Polish "Drop support for "all" from management.metrics.distribution.sla" Drop support for "all" from management.metrics.distribution.sla
this enhancement