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
Allow distribution config customization #4829
Allow distribution config customization #4829
Conversation
To be honest, I'm not sure if this is right direction. 😱 |
|
||
@Override | ||
public DistributionStatisticConfig distributionStatisticConfig() { | ||
return DistributionStatisticConfig.DEFAULT; |
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.
We don't use DistributionStatisticConfig.DEFAULT
as default.
We use
DistributionStatisticConfig.builder()
.percentilesHistogram(false)
.sla()
.percentiles(PERCENTILES)
.percentilePrecision(2)
.minimumExpectedValue(1L)
.maximumExpectedValue(Long.MAX_VALUE)
.expiry(Duration.ofMinutes(3))
.bufferLength(3)
.build();
from MoreMeters.distStatCfg
as default instead. So we need to:
- Define the default config in
MoreMeters.DEFAULT_DIST_STAT_CFG
private static volatile DistributionStatisticConfig DEFAULT_DIST_STAT_CFG = DistributionStatisticConfig.builder() .percentilesHistogram(false) .sla() .percentiles(PERCENTILES) .percentilePrecision(2) .minimumExpectedValue(1L) .maximumExpectedValue(Long.MAX_VALUE) .expiry(Duration.ofMinutes(3)) .bufferLength(3) .build();
- Use the value from the DefaultFlagsProvider:
@Override public DistributionStatisticConfig distributionStatisticConfig() { return MoreMeters.defaultDistributionStatisticConfig(); }
- Set the
Flags.distributionStatisticConfig()
todistStatCfg
.private static volatile DistributionStatisticConfig distStatCfg = Flags.distributionStatisticConfig();
In this way, we can add this new API without breaking the behavior.
Now, we need to use the MoreMeters.distributionStatisticConfig()
as the default value for the AbstractMetricCollectingBuilder
:
public abstract class AbstractMetricCollectingBuilder {
private DistributionStatisticConfig distributionStatisticConfig = MoreMeters.distributionStatisticConfig;
}
The distributionStatisticConfig
will be passed to the constructor of MetricCollectingClient
and MetricCollectingService
and it will be also passed to RequestMetricSupport.setup(...)
.
It will be eventually used to create the summary here: https://github.com/line/armeria/blob/main/core/src/main/java/com/linecorp/armeria/internal/common/metric/RequestMetricSupport.java#L221
(MoreMeters.newDistributionSummary()
method no longer need to be in MoreMeters
. We can move it to RequestMetricSupport
as a private method.)
Please let me know if there's anything unclear. 😄
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 feedback!
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.
@minwoox
I implemented as you mentioned above but setting MoreMeters.distStatCfg
from Flags.distributionStatisticConfig()
doesn't work well on some tests.
It complains that MoteMeters.distStatCfg
is null
. So I checked the failed test from local environment and I got this.
In theory, Flags.DISTRIBUTION_STATISTIC_CONFIG
should be populated by DefaultFlagsProvider.distributionStatisticConfig()
and thus MoreMeters.distStatCfg
should be populated by `Flags.distributionStatisticConfig().
But in fact, it's null. Maybe there is some timing issue...or circular referencing...or whatever unknown problem.
Any idea?
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.
Sorry about the problem. 😅
The DEFAULT_DIST_STAT_CFG
is not instantiated before defaultDistributionStatisticConfig()
is called. 😓
Let's move it to another class:
package com.linecorp.armeria.internal.common.metric;
...
public final class DistributionStatisticConfigUtil {
public static final DistributionStatisticConfig DEFAULT_DIST_STAT_CFG =
DistributionStatisticConfig.builder()...
...
}
// DefaultFlagProvider
@Override
public DistributionStatisticConfig distributionStatisticConfig() {
return DistributionStatisticConfigUtil.DEFAULT_DIST_STAT_CFG;
}
- Use MoreMeters default distribution config as default
core/src/main/java/com/linecorp/armeria/common/metric/AbstractMetricCollectingBuilder.java
Show resolved
Hide resolved
- allow MetricCollecting{Client,RpcClient,Service} to receive DistributionStatisticConfig
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, @echo304! Left some comments you might want to take a look. 🙇
@@ -1343,6 +1347,16 @@ public static long defaultUnhandledExceptionsReportIntervalMillis() { | |||
return DEFAULT_UNHANDLED_EXCEPTIONS_REPORT_INTERVAL_MILLIS; | |||
} | |||
|
|||
/** | |||
* Returns the {@link DistributionStatisticConfig} where armeria utilizes. |
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.
* Returns the {@link DistributionStatisticConfig} where armeria utilizes. | |
* Returns the default {@link DistributionStatisticConfig} of the {@link Timer}s and {@link DistributionSummary}s created by Armeria. |
/** | ||
* Returns the {@link DistributionStatisticConfig} where armeria utilizes. | ||
* | ||
* <p>The default value of this flag is {@link DistributionStatisticConfig#DEFAULT}</p> |
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 needs an update. We could paste some code here:
<p>The default value of this flag is as follows:
<pre>{@code
DistributionStatisticConfig
.builder()
...
.build();
}</pre>
/** | ||
* Returns the {@link DistributionStatisticConfig} where armeria utilizes. | ||
* | ||
* <p>The default value of this flag is {@link DistributionStatisticConfig#DEFAULT}</p> | ||
*/ |
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.
Ditto - please keep in sync with Flags.distributionStatisticConfig()
.
public final class DistributionStatisticConfigUtil { | ||
private static final double[] PERCENTILES = { 0, 0.5, 0.75, 0.9, 0.95, 0.98, 0.99, 0.999, 1.0 }; | ||
|
||
public static final DistributionStatisticConfig DEFAULT_DIST_STAT_CFG = | ||
DistributionStatisticConfig.builder() |
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.
Could you reformat this file?
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig; | ||
|
||
public final class DistributionStatisticConfigUtil { | ||
private static final double[] PERCENTILES = { 0, 0.5, 0.75, 0.9, 0.95, 0.98, 0.99, 0.999, 1.0 }; |
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.
It's used only once, so I guess we can inline it.
core/src/main/java/com/linecorp/armeria/server/metric/MetricCollectingService.java
Show resolved
Hide resolved
Approved by mistake. Sorry! 🙏 |
- Fix comments - Reformat a file
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.
Let's keep moving on. 😆
core/src/main/java/com/linecorp/armeria/client/metric/AbstractMetricCollectingClient.java
Outdated
Show resolved
Hide resolved
- Override MoreMeters.distributionStatisticConfig from RequestMetricSupport.setup
@@ -66,6 +68,8 @@ public static void setup( | |||
RequestLogProperty.NAME, | |||
RequestLogProperty.SESSION) | |||
.thenAccept(log -> onRequest(log, meterIdPrefixFunction, server, successFunction)); | |||
|
|||
MoreMeters.setDistributionStatisticConfig(distributionStatisticConfig); |
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.
Instead of your advice(#4829 (comment)), I've override a distributionStatisticConfig from here.
Do you think this is too dangerous approach?
@minwoox
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.
It is not thread safe. The two requests having different DistributionStatisticConfig
s update the global DistributionStatisticConfig
concurrently, the result is unpredictable.
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.
That makes sense to me 😞
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.
As @ikhoon said, we can't just set the config here.
Is there any reason that you are reluctant to use the config in the onResponse
method?
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.
Let's pass it to the
setup
method inexecute(...)
so we can use it when creating the distribution:RequestMetricSupport.setup(ctx, REQUEST_METRICS_SET, meterIdPrefixFunction, false, successFunction != null ? successFunction::test : ctx.options().successFunction(), distributionStatisticConfig);
In
RequestMetricSupport
private static void onRequest( RequestLog log, MeterIdPrefixFunction meterIdPrefixFunction, boolean server, SuccessFunction successFunction, DistributionStatisticConfig distStatCfg) { ...} private static void onResponse( RequestLog log, MeterIdPrefixFunction meterIdPrefixFunction, boolean server, SuccessFunction successFunction, DistributionStatisticConfig distStatCfg) { ... new DefaultClientRequestMetrics(distStatCfg); ... new DefaultServiceRequestMetrics(distStatCfg); ... }
@minwoox I looked into DefaultClientRequestMetrics
class but it seems like there is no injection point as of now.
Because the constructor of the class calls MoreMeters.newTimer()
but to pass given distStatCfg
I need to change current implementation of newTimer()
.
That's why I tried to use setter of MoreMeters
.
If you meant that I do modify newTimer
method signature and its logic, just let me know. I will do it :)
@@ -36,6 +38,9 @@ public abstract class AbstractMetricCollectingBuilder { | |||
@Nullable | |||
private BiPredicate<? super RequestContext, ? super RequestLog> successFunction; | |||
|
|||
@Nullable |
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.
@Nullable |
/** | ||
* Returns the {@code distributionStatisticConfig}. | ||
*/ | ||
@Nullable |
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.
@Nullable |
# Conflicts: # core/src/main/java/com/linecorp/armeria/internal/common/metric/RequestMetricSupport.java # core/src/main/java/com/linecorp/armeria/server/metric/MetricCollectingService.java
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.
Left only minor comments. I think it's almost done. 😄
|
||
AbstractMetricCollectingClient( | ||
Client<I, O> delegate, MeterIdPrefixFunction meterIdPrefixFunction, | ||
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction) { | ||
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction, | ||
@Nullable DistributionStatisticConfig distributionStatisticConfig) { |
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.
@Nullable DistributionStatisticConfig distributionStatisticConfig) { | |
DistributionStatisticConfig distributionStatisticConfig) { |
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction) { | ||
super(delegate, meterIdPrefixFunction, successFunction); | ||
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction, | ||
@Nullable DistributionStatisticConfig distributionStatisticConfig) { |
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.
@Nullable DistributionStatisticConfig distributionStatisticConfig) { | |
DistributionStatisticConfig distributionStatisticConfig) { |
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction) { | ||
super(delegate, meterIdPrefixFunction, successFunction); | ||
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction, | ||
@Nullable DistributionStatisticConfig distributionStatisticConfig) { |
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.
@Nullable DistributionStatisticConfig distributionStatisticConfig) { | |
DistributionStatisticConfig distributionStatisticConfig) { |
* DistributionStatisticConfig.builder() | ||
* .percentilesHistogram(false) | ||
* .sla() | ||
* .percentiles(PERCENTILES) | ||
* .percentilePrecision(2) | ||
* .minimumExpectedValue(1L) | ||
* .maximumExpectedValue(Long.MAX_VALUE) | ||
* .expiry(Duration.ofMinutes(3)) | ||
* .bufferLength(3) | ||
* .build(); |
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.
It seems like some of the methods are deprecated. Could you fix it, please? 🙏
requireNonNull(registry, "registry"); | ||
requireNonNull(name, "name"); | ||
requireNonNull(tags, "tags"); | ||
requireNonNull(distStatCfgOverride, "distributionStatisticConfig"); |
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.
nit: The name should be the same:
requireNonNull(distStatCfgOverride, "distributionStatisticConfig"); | |
requireNonNull(distStatCfgOverride, "distStatCfgOverride"); |
Also, how about removing Override
? If you worry about naming the same with the field, we might rename it to distStatsConfig
.
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.
Got it!
Following your advice, I will change the name of the field to distStatsConfig
and same for the string "distStatsConfig"
.
requireNonNull(registry, "registry"); | ||
requireNonNull(name, "name"); | ||
requireNonNull(tags, "tags"); | ||
requireNonNull(distStatCfgOverride, "distributionStatisticConfig"); |
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.
ditto
|
||
MetricCollectingService(HttpService delegate, | ||
MeterIdPrefixFunction meterIdPrefixFunction, | ||
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction) { | ||
@Nullable BiPredicate<? super RequestContext, ? super RequestLog> successFunction, | ||
@Nullable DistributionStatisticConfig distributionStatisticConfig) { |
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.
@Nullable DistributionStatisticConfig distributionStatisticConfig) { | |
DistributionStatisticConfig distributionStatisticConfig) { |
RequestMetricSupport.setup(ctx, REQUEST_METRICS_SET, meterIdPrefixFunction, false, | ||
SuccessFunction.ofDefault()); | ||
SuccessFunction.ofDefault(), distributionStatisticConfig); |
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.
Let's inline:
SuccessFunction.ofDefault(), distributionStatisticConfig); | |
SuccessFunction.ofDefault(), DEFAULT_DIST_STAT_CFG); |
RequestMetricSupport.setup(ctx, REQUEST_METRICS_SET, meterIdPrefixFunction, true, | ||
SuccessFunction.ofDefault()); | ||
SuccessFunction.ofDefault(), distributionStatisticConfig); |
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.
SuccessFunction.ofDefault(), distributionStatisticConfig); | |
SuccessFunction.ofDefault(), DEFAULT_DIST_STAT_CFG); |
Please also fix the below changes as well. 😉
.serviceLevelObjectives() | ||
.percentiles( | ||
0, 0.5, 0.75, 0.9, 0.95, 0.98, 0.99, 0.999, 1.0) | ||
.percentilePrecision(2) | ||
.minimumExpectedValue(1.0) | ||
.maximumExpectedValue(Double.MAX_VALUE) |
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.
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.
Yeah, it looks good! 👍
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.
Left only minor comments. Thanks @echo304! 👍 👍
super(delegate); | ||
this.meterIdPrefixFunction = requireNonNull(meterIdPrefixFunction, "meterIdPrefixFunction"); | ||
this.successFunction = successFunction; | ||
this.distributionStatisticConfig = distributionStatisticConfig; |
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.
Let's add requireNonNull
for consistency.
* .percentilesHistogram(false) | ||
* .sla() | ||
* .percentiles(PERCENTILES) | ||
* .percentilePrecision(2) | ||
* .minimumExpectedValue(1L) | ||
* .maximumExpectedValue(Long.MAX_VALUE) | ||
* .expiry(Duration.ofMinutes(3)) |
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.
It seems like we should also fix this. 😉
super(delegate); | ||
this.meterIdPrefixFunction = requireNonNull(meterIdPrefixFunction, "meterIdPrefixFunction"); | ||
this.successFunction = successFunction; | ||
this.distributionStatisticConfig = distributionStatisticConfig; |
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.
ditto
RequestMetricSupport.setup(sctx, REQUEST_METRICS_SET, | ||
MeterIdPrefixFunction.ofDefault("foo"), true, | ||
SuccessFunction.ofDefault()); | ||
SuccessFunction.ofDefault(), distributionStatisticConfig); |
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.
Let's just inline. 😉
@@ -388,7 +391,7 @@ void serviceAndClientContext() { | |||
.build(); | |||
RequestMetricSupport.setup(cctx, AttributeKey.valueOf("differentKey"), | |||
MeterIdPrefixFunction.ofDefault("bar"), false, | |||
SuccessFunction.ofDefault()); | |||
SuccessFunction.ofDefault(), distributionStatisticConfig); |
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.
ditto
@@ -439,12 +442,15 @@ void customSuccessFunction() { | |||
.build(); | |||
|
|||
final MeterIdPrefixFunction meterIdPrefixFunction = MeterIdPrefixFunction.ofDefault("foo"); | |||
final DistributionStatisticConfig distributionStatisticConfig = DEFAULT_DIST_STAT_CFG; |
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.
ditto
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.
Left only minor comments. Thanks @echo304! 👍 👍
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4829 +/- ##
============================================
+ Coverage 74.03% 74.05% +0.01%
- Complexity 20854 20865 +11
============================================
Files 1807 1808 +1
Lines 76754 76790 +36
Branches 9790 9792 +2
============================================
+ Hits 56827 56865 +38
Misses 15301 15301
+ Partials 4626 4624 -2 ☔ View full report in Codecov by Sentry. |
Could you add more tests for |
* DistributionStatisticConfig.builder() | ||
* .percentilesHistogram(false) | ||
* .serviceLevelObjectives() | ||
* .percentiles(PERCENTILES) |
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.
Should we inline PERCENTILES
to show the actual value?
* DistributionStatisticConfig.builder() | ||
* .percentilesHistogram(false) | ||
* .serviceLevelObjectives() | ||
* .percentiles(PERCENTILES) |
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.
Should we inline PERCENTILES
to show the actual value?
.expiry(Duration.ofMinutes(3)) | ||
.bufferLength(3) | ||
.build(); | ||
private static volatile DistributionStatisticConfig distStatCfg = Flags.distributionStatisticConfig(); |
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.
private static volatile DistributionStatisticConfig distStatCfg = Flags.distributionStatisticConfig(); | |
private static volatile DistributionStatisticConfig defaultDistStatCfg = Flags.distributionStatisticConfig(); |
Please check the lint failure. |
requireNonNull(registry, "registry"); | ||
requireNonNull(name, "name"); | ||
requireNonNull(tags, "tags"); | ||
requireNonNull(distStatsConfig, "distStatCfg"); |
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.
requireNonNull(distStatsConfig, "distStatCfg"); | |
requireNonNull(distStatsConfig, "distStatsConfig"); |
requireNonNull(registry, "registry"); | ||
requireNonNull(name, "name"); | ||
requireNonNull(tags, "tags"); | ||
requireNonNull(distStatsConfig, "distStatCfg"); |
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.
requireNonNull(distStatsConfig, "distStatCfg"); | |
requireNonNull(distStatsConfig, "distStatsConfig"); |
assertThat(abstractMetricCollectingBuilder.distributionStatisticConfig()) | ||
.isEqualTo(distConfig); | ||
} | ||
} |
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.
Should we add an EOL character?
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.
} | |
} | |
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.
Mostly looks good. Left two comments 🙇
DefaultClientRequestMetrics(MeterRegistry parent, MeterIdPrefix idPrefix) { | ||
super(parent, idPrefix); | ||
DefaultClientRequestMetrics(MeterRegistry parent, MeterIdPrefix idPrefix, | ||
DistributionStatisticConfig distributionStatisticConfig) { |
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.
Shouldn't we also use this distributionStatisticConfig
for timers/distributions in this class?
armeria/core/src/main/java/com/linecorp/armeria/internal/common/metric/RequestMetricSupport.java
Lines 316 to 323 in 337c09c
connectionAcquisitionDuration = newTimer( | |
parent, idPrefix.name("connection.acquisition.duration"), idPrefix.tags()); | |
dnsResolutionDuration = newTimer( | |
parent, idPrefix.name("dns.resolution.duration"), idPrefix.tags()); | |
socketConnectDuration = newTimer( | |
parent, idPrefix.name("socket.connect.duration"), idPrefix.tags()); | |
pendingAcquisitionDuration = newTimer( | |
parent, idPrefix.name("pending.acquisition.duration"), idPrefix.tags()); |
armeria/core/src/main/java/com/linecorp/armeria/internal/common/metric/RequestMetricSupport.java
Lines 369 to 386 in 337c09c
public DistributionSummary successAttempts() { | |
if (successAttempts != null) { | |
return successAttempts; | |
} | |
return successAttempts = newDistributionSummary(parent, | |
idPrefix.name("actual.requests.attempts"), | |
idPrefix.tags("result", "success")); | |
} | |
@Override | |
public DistributionSummary failureAttempts() { | |
if (failureAttempts != null) { | |
return failureAttempts; | |
} | |
return failureAttempts = newDistributionSummary(parent, | |
idPrefix.name("actual.requests.attempts"), | |
idPrefix.tags("result", "failure")); | |
} |
/** | ||
* Defines a custom {@link DistributionStatisticConfig} to use for the distribution config. | ||
*/ | ||
public AbstractMetricCollectingBuilder distributionStatisticConfig( |
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.
Shouldn't we also override this method in child classes?
i.e. the following won't compile:
MetricCollectingClient.builder(MeterIdPrefixFunction.ofDefault("armeria"))
.distributionStatisticConfig(DistributionStatisticConfig.DEFAULT)
.newDecorator()
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.
Shouldn't our builder test (com.linecorp.armeria.OverriddenBuilderMethodsReturnTypeTest
) catch this issue automatically? Let's make sure this PR is failed by it first.
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.
Shouldn't our builder test (com.linecorp.armeria.OverriddenBuilderMethodsReturnTypeTest) catch this issue automatically?
The builder isn't final 😅
armeria/it/builders/src/test/java/com/linecorp/armeria/OverriddenBuilderMethodsReturnTypeTest.java
Line 51 in 5df7f16
Modifier.isFinal(clazz.getModifiers())) |
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.
👍 👍 👍
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.
Nice work! 🚀🚀
Motivation:
As of now, users need to use
MoreMeters.setDistributionStatisticConfig(config)
to specify the distribution config.It prevents users from configuring different configs depending on the client.
This PR is to resolve above issue.
Modifications:
distributionStatisticConfig
getter toFlagsProvider
andDefaultFlagsProvider
distributionStatisticConfig
setter and getter toAbstractMetricCollectingBuilder
Result: