feat: track DNS request source in metrics and logs#122
Merged
Conversation
Introduce `DNSSource` and `RequestContext` to differentiate between UDP, TCP, and DoT requests throughout the dispatching lifecycle. - Update `DNSDispatcher` to accept the request source. - Enhance `dns_request_count` metric with a `source` label. - Consolidate logging context to include source and metadata.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the DNS request handling to track and report the source of DNS requests (UDP, TCP, or DoT) in metrics and logs. It introduces a DNSSource type and a RequestContext struct to pass contextual information through the dispatcher. The review feedback suggests several improvements: removing the unused StartTime field from RequestContext, and skipping both the geolocation lookup and client count updates when the client IP address is resolved as "unknown" to avoid redundant operations and duplicate warning logs.
Coverage Report for CI Build 26707628692Coverage increased (+0.2%) to 39.922%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
- Refactored `RequestContext` to use `time.Time` instead of `*time.Time`. - Moved client tracking logic directly into `HandleDNSRequest` to reduce function call overhead and improve readability. - Removed redundant `updateClientCount` helper method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce
DNSSourceandRequestContextto differentiate between UDP, TCP, and DoT requests throughout the dispatching lifecycle.DNSDispatcherto accept the request source.dns_request_countmetric with asourcelabel.