-
Notifications
You must be signed in to change notification settings - Fork 909
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
Provide a way to disable DnsQueryLifecycleObserverFactory
#3552
Conversation
Motivation: Some users might not want to monitor DNS metrics if a client sends requests to unspecified domains such as webhook domains or redirect locations. In that case, the cardinality of the metrics could be huge because of various domain names. Modifications: - Add `disableDnsQueryLifecycleObserverFactory()` option to `DnsResolverGroupBuilder` Result: - You can now disable DNS metrics using `DnsResolverGroupBuilder.disableDnsQueryLifecycleObserverFactory()`. ```java ClientFactory.builder() .domainNameResolverCustomizer(builder -> { builder.disableDnsQueryLifecycleObserverFactory(); }) ``` - Fixes line#3368
@@ -361,13 +376,17 @@ RefreshingAddressResolverGroup build(EventLoopGroup eventLoopGroup) { | |||
new DefaultDnsQueryLifecycleObserverFactory( |
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.
observerFactory
is not used when disableDnsQueryLifecycleObserverFactory
is false so we should remove it. 😄
new BiDnsQueryLifecycleObserverFactory(observerFactory, | ||
dnsQueryLifecycleObserverFactory)); | ||
|
||
if (!disableDnsQueryLifecycleObserverFactory) { |
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 guess there might be a chance that a user wants to set a customized DnsQueryLifecycleObserver
while he/she doesn't want to use the DefaultDnsQueryLifecycleObserverFactory
.
So how about changing the parameter to disableDnsQueryMetric
and allow users to use the customized factory?
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.
+1 Nice idea.
Codecov Report
@@ Coverage Diff @@
## master #3552 +/- ##
==========================================
Coverage 73.92% 73.92%
- Complexity 14210 14241 +31
==========================================
Files 1245 1248 +3
Lines 54193 54327 +134
Branches 6930 6938 +8
==========================================
+ Hits 40060 40162 +102
- Misses 10592 10627 +35
+ Partials 3541 3538 -3 Continue to review full report at Codecov.
|
Thread.sleep(1000); | ||
assertThat(MoreMeters.measureAll(meterRegistry).entrySet().stream() | ||
.anyMatch(entry -> entry.getKey() | ||
.contains("armeria.client.dns.queries"))) |
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.
.contains("armeria.client.dns.queries"))) | |
.startsWith("armeria.client.dns."))) |
"armeria.client.dns.queries#count{" + | ||
"cause=others,name=bar.com.,result=failure}"; | ||
assertThat(MoreMeters.measureAll(meterRegistry)) | ||
.doesNotContainKeys(writeMeterId, successMeterId); |
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.
How about making sure there are no meters that start with armeria.client.dns.
?
@@ -90,6 +90,7 @@ | |||
private DnsServerAddressStreamProvider dnsServerAddressStreamProvider; | |||
@Nullable | |||
private DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory; | |||
private boolean disableDnsQueryMetric; |
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.
dnsQueryMetricsDisabled
?
* Disables the default {@link DnsQueryLifecycleObserverFactory} that collects DNS query metrics through | ||
* {@link MeterRegistry}. | ||
*/ | ||
public DnsResolverGroupBuilder disableDnsQueryMetric() { |
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.
disableDnsQueryMetrics
(s at the end)
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.
LGTM once @trustin's comments are addressed. 😄
…SimpleMeterRegistry
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, @ikhoon !
Motivation:
Some users might not want to monitor DNS metrics
if a client sends requests to unspecified domains
such as webhook domains or redirect locations.
In that case, the cardinality of the metrics could be huge
because of various domain names.
Modifications:
disableDnsQueryLifecycleObserverFactory()
option toDnsResolverGroupBuilder
Result:
DnsResolverGroupBuilder.disableDnsQueryMetrics()
.