Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thevilledev
Copy link
Collaborator

@thevilledev thevilledev commented May 20, 2025

1. Why is this pull request needed and what does it do?

The rewrite plugin modifies DNS messages, affecting the request size observed in the coredns_dns_request_size_bytes metric.

This change captures the original request size before any plugins can modify it. It adds a functional options pattern to Report() to pass this information while maintaining API compatibility.

Tests have been added to verify the fix prevents rewrite from affecting the request size metrics. If the same test is run against master it fails as follows:

=== RUN   TestMetricsRewriteRequestSize
    metrics_test.go:174: Available metrics without rewrite:
    metrics_test.go:125:   coredns_dns_request_size_bytes: [{map[proto:udp server:dns://:0 view: zone:.] map[0:0 100:5 1023:5 16000:5 200:5 2047:5 300:5 32000:5 400:5 4095:5 48000:5 511:5 64000:5 8291:5] 5 0}]
    metrics_test.go:207: Available metrics with rewrite:
    metrics_test.go:125:   coredns_dns_request_size_bytes: [{map[proto:udp server:dns://:0 view: zone:.] map[0:0 100:5 1023:10 16000:10 200:10 2047:10 300:10 32000:10 400:10 4095:10 48000:10 511:10 64000:10 8291:10] 10 0}]
    metrics_test.go:225: Expected all requests to go to le=100 bucket
--- FAIL: TestMetricsRewriteRequestSize (0.35s)

Prometheus utilities used in the test file brought in a new dependency to go.mod.

Includes a small docs update.

2. Which issues (if any) are related?

Fixes #7162

3. Which documentation changes (if any) need to be made?

None.

4. Does this introduce a backward incompatible change or deprecation?

No. After this correction has been merged, users utilising these request size metrics might notice a difference if rewrite plugin is used.

@codecov
Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.77%. Comparing base (93c57b6) to head (2f9b7c9).
Report is 1455 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7313      +/-   ##
==========================================
+ Coverage   55.70%   57.77%   +2.07%     
==========================================
  Files         224      273      +49     
  Lines       10016    17912    +7896     
==========================================
+ Hits         5579    10348    +4769     
- Misses       3978     6952    +2974     
- Partials      459      612     +153     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thevilledev thevilledev force-pushed the fix/issue-7162 branch 3 times, most recently from 37eef4f to dfb7866 Compare May 20, 2025 19:48
The rewrite plugin modifies DNS messages, affecting the request
size observed in the coredns_dns_request_size_bytes metric.

This change captures the original request size before any plugins
can modify it. It adds a functional options pattern to Report() to
pass this information while maintaining API compatibility.

Tests have been added to verify the fix prevents rewrite from
affecting the request size metrics.

Docs included.

Signed-off-by: Ville Vesilehto <[email protected]>
@yongtang yongtang merged commit 32ea433 into coredns:master May 22, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite plugin affects coredns_dns_request_size_bytes metric

2 participants