Skip to content
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

Merged
merged 3 commits into from
May 14, 2021

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented May 12, 2021

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:

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
@ikhoon ikhoon added this to the 1.8.0 milestone May 12, 2021
@@ -361,13 +376,17 @@ RefreshingAddressResolverGroup build(EventLoopGroup eventLoopGroup) {
new DefaultDnsQueryLifecycleObserverFactory(
Copy link
Member

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) {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Nice idea.

@codecov
Copy link

codecov bot commented May 12, 2021

Codecov Report

Merging #3552 (f029e78) into master (3c89a1f) will increase coverage by 0.00%.
The diff coverage is 77.77%.

❗ Current head f029e78 differs from pull request most recent head 781a286. Consider uploading reports for the commit 781a286 to get more accurate results
Impacted file tree graph

@@            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     
Impacted Files Coverage Δ Complexity Δ
...necorp/armeria/client/DnsResolverGroupBuilder.java 56.00% <77.77%> (+2.80%) 22.00 <1.00> (+3.00)
...rp/armeria/server/tomcat/ManagedTomcatService.java 50.84% <0.00%> (-22.04%) 6.00% <0.00%> (-1.00%)
...nternal/server/tomcat/Tomcat90ProtocolHandler.java 50.00% <0.00%> (-15.39%) 11.00% <0.00%> (-4.00%)
...rp/armeria/server/tomcat/TomcatServiceBuilder.java 36.36% <0.00%> (-10.91%) 4.00% <0.00%> (-1.00%)
...com/linecorp/armeria/common/DefaultRpcRequest.java 65.30% <0.00%> (-8.51%) 15.00% <0.00%> (+2.00%) ⬇️
...ecorp/armeria/common/stream/StreamMessageUtil.java 76.66% <0.00%> (-6.67%) 11.00% <0.00%> (-1.00%)
...p/armeria/common/stream/AbstractStreamMessage.java 81.73% <0.00%> (-5.77%) 15.00% <0.00%> (ø%)
...rmeria/common/stream/ConcatArrayStreamMessage.java 75.82% <0.00%> (-2.20%) 9.00% <0.00%> (-1.00%)
...uth/oauth2/OAuth2TokenIntrospectionAuthorizer.java 63.15% <0.00%> (-1.76%) 11.00% <0.00%> (-1.00%)
...inecorp/armeria/server/grpc/FramedGrpcService.java 81.95% <0.00%> (-0.49%) 30.00% <0.00%> (ø%)
... and 27 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c89a1f...781a286. Read the comment docs.

Thread.sleep(1000);
assertThat(MoreMeters.measureAll(meterRegistry).entrySet().stream()
.anyMatch(entry -> entry.getKey()
.contains("armeria.client.dns.queries")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.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);
Copy link
Member

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;
Copy link
Member

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() {
Copy link
Member

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)

Copy link
Member

@minwoox minwoox left a 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. 😄

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ikhoon !

@trustin trustin merged commit b5a2e1c into line:master May 14, 2021
@ikhoon ikhoon deleted the disable-dns-metrics-option branch May 27, 2021 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way to disable the default DNS metrics
3 participants