Skip to content

fix: buffer metrics collection in RequestContext#136

Merged
rm-hull merged 7 commits into
mainfrom
fix/hot-paths
Jun 2, 2026
Merged

fix: buffer metrics collection in RequestContext#136
rm-hull merged 7 commits into
mainfrom
fix/hot-paths

Conversation

@rm-hull
Copy link
Copy Markdown
Owner

@rm-hull rm-hull commented Jun 2, 2026

Refactored telemetry recording to collect data within RequestContext instead of immediate metric emission. This ensures consistency and avoids partial updates during request processing.

Refactored telemetry recording to collect data within `RequestContext`
instead of immediate metric emission. This ensures consistency and
avoids partial updates during request processing.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

TestsPassed ✅SkippedFailed
JUnit Test Report46 ran46 passed0 skipped0 failed
TestResult
JUnit Test Report
com/rm-hull/dot-block/internal/blocklist.TestIsBlocked_ApexDomain_PublicSuffix✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_MixedBlockedAndUpstream✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_Allowed✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_Blocked✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_MultipleQuestions✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_CacheHit✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ResolveUpstream_BadRCode✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_NegativeCacheTtlFloor✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_DNSSD_NXDOMAIN✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_UpstreamNXDOMAIN_NoLogError✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_UpstreamNOTIMP_NoLogError✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_HandleDNSRequest_UpstreamSERVFAIL_LogError✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs/example.invalid.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs/localhost.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs/test.local.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs/my.test.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs/my.example.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs/my.internal.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestDNSDispatcher_ReservedTLDs✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/db._dns-sd._udp.0.68.168.192.in-addr.arpa.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/b._dns-sd._udp.local.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/r._dns-sd._udp.example.com.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/dr._dns-sd._udp.example.com.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/lb._dns-sd._udp.example.com.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/example.com.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/_dns-sd._udp.example.com.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery/_services._dns-sd._udp.example.com.✅ passed
com/rm-hull/dot-block/internal/forwarder.TestIsDNSSDQuery✅ passed
com/rm-hull/dot-block/internal/metrics.TestNewSpaceSaverStatsCallback/eviction_case✅ passed
com/rm-hull/dot-block/internal/metrics.TestNewSpaceSaverStatsCallback/topK_smaller_than_items✅ passed
com/rm-hull/dot-block/internal/metrics.TestNewSpaceSaverStatsCallback/empty_space_saver✅ passed
com/rm-hull/dot-block/internal/metrics.TestNewSpaceSaverStatsCallback✅ passed
com/rm-hull/dot-block/internal/metrics.TestNewSpaceSaver✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverAdd/Case3_ReplacementDetails✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverAdd✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverTopN/TopN_WithReplacements✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverTopN✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverConcurrency✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching/MinKeyInitialization✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching/MinKeyAfterFirstAdd✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching/MinKeyAddingItemsWithSameCount✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching/MinKeyAfterIncrementingMinKeyItem✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching/MinKeyAfterReplacement✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching/MinKeyInvalidationAndRecomputation✅ passed
com/rm-hull/dot-block/internal/metrics.TestSpaceSaverMinKeyCaching✅ passed
com/rm-hull/dot-block/internal/mobileconfig.TestHandler✅ passed

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

The refactoring to buffer metrics in RequestContext is a good improvement for consistency and performance by reducing the number of direct metric updates during request processing. However, I found a bug in reportError where metrics are still being recorded immediately.

Comment thread internal/forwarder/dispatcher.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed the pull request #136. The refactoring to buffer metrics in RequestContext is a solid improvement for consistency and performance.

However, I found one remaining instance where metrics are still emitted immediately. In the reportError function, d.metrics.ErrorCounts.WithLabelValues(errorCategory).Inc() is still being called directly. This should be removed and handled within recordTelemetry using the ctx.errorCategory field to maintain consistency with the rest of the changes.

I have posted a PR review requesting this change.


View action run | Model: google/gemma-4-31b-it | Time: 1m 8s | Tokens: 63.5K | Pi SDK v0.75.5 | Action v2.18.0

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors telemetry collection in the DNS forwarder by storing metrics data in the RequestContext and deferring recording to recordTelemetry. The reviewer provided valuable feedback to address a double-counting bug in ErrorCounts, prevent overwriting of upstream TTLs by using a slice instead of a single pointer, simplify the tracking of forwarded requests using a boolean flag instead of a slice of strings, and optimize boolean-to-string conversion to avoid allocations on a high-throughput path.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/forwarder/dispatcher.go Outdated
blockedDomains []string
domains []string
queryCounts []queryCountInfo
upstreamTTL *upstreamTTLInfo
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since a single DNS request can contain multiple questions, we should store all upstream TTLs in a slice instead of a single pointer to avoid overwriting previous values in the loop.

Suggested change
upstreamTTL *upstreamTTLInfo
upstreamTTLs []upstreamTTLInfo

Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/forwarder/dispatcher.go Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Jun 2, 2026

Coverage Report for CI Build 26842254699

Warning

No base build found for commit 43c11d3 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 47.388%

Details

  • Patch coverage: 4 uncovered changes across 2 files (103 of 107 lines covered, 96.26%).

Uncovered Changes

File Changed Covered %
internal/app.go 2 0 0.0%
internal/metrics/telemetry.go 80 78 97.5%
Total (4 files) 107 103 96.26%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 1646
Covered Lines: 780
Line Coverage: 47.39%
Coverage Strength: 1046.28 hits per line

💛 - Coveralls

Move the telemetry recording logic from `DNSDispatcher` to
`metrics.DnsMetrics` to encapsulate metric operations and reduce
dependency on the dispatcher.

- Introduced `TelemetryData` struct to hold request-scoped telemetry.
- Migrated all `prometheus` recording operations into
`DnsMetrics.RecordTelemetry`.
- Moved geolocation lookup to the background worker to ensure cleaner
data collection flow.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

The refactoring to buffer metrics in RequestContext is a good architectural move to ensure consistency and improve performance by reducing direct metric emission in the request hot path.

However, there are several issues and optimization opportunities that should be addressed:

  1. Incorrect Handling of Multiple Questions: A single DNS request can contain multiple questions. The current implementation uses a single pointer UpstreamTTL *UpstreamTTLInfo in TelemetryData, which means only the TTL of the last processed question is recorded. This should be changed to a slice.
  2. Inefficient Boolean-to-String Conversion: In RecordTelemetry, fmt.Sprintf("%t", qc.Blocked) is used in a loop. This is expensive in a high-throughput path. A simple conditional should be used instead.
  3. Redundant Slice Allocations: RequestTypes is used as a slice of strings to track if a request was forwarded or errored. Since these are binary states for a request, using boolean flags (e.g., Forwarded bool, Errored bool) would be more efficient and avoid unnecessary allocations and potential double-counting if multiple errors occur.

I recommend applying the suggestions already mentioned in the PR comments by @gemini-code-assist[bot] to resolve these issues.

Comment thread internal/forwarder/dispatcher.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed pull request #136. While the move to buffer metrics in RequestContext is a positive architectural change for consistency and performance, I have identified several issues that need to be addressed before merging.

Key Findings:

  • Data Loss on Multi-Question Requests: The current implementation uses a single pointer for UpstreamTTL in TelemetryData. Since a single DNS request can contain multiple questions, only the TTL of the last processed question is recorded, leading to inaccurate metrics. This should be changed to a slice.
  • Performance Bottleneck in Telemetry Path: The use of fmt.Sprintf("%t", qc.Blocked) within a loop in RecordTelemetry introduces unnecessary allocations and overhead in a high-throughput code path. This should be replaced with a simple conditional.
  • Inefficient Request Type Tracking: The use of a slice of strings (RequestTypes) to track if a request was forwarded or errored is inefficient. Using boolean flags would avoid slice allocations and prevent potential double-counting of errored requests.

I have posted a PR review with a REQUEST_CHANGES status and provided specific inline comments. I strongly recommend incorporating the suggestions already provided by @gemini-code-assist[bot] in the PR thread to resolve these issues.


View action run | Model: google/gemma-4-31b-it | Time: 1m 19s | Tokens: 63.9K | Pi SDK v0.78.0 | Action v2.18.0

Centralize geolocation logic within the `metrics` package by injecting
the `GeoIpLookup` interface directly into `DnsMetrics`. This removes the
 dependency from the `DNSDispatcher` and simplifies the telemetry
recording flow.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

I have reviewed the changes in PR #136. While moving telemetry collection to RequestContext is a good architectural improvement, there are several issues that need to be addressed, most of which were previously highlighted in the PR thread but have not yet been implemented.

Critical Issues

  1. Data Loss on Multi-Question Requests:
    In internal/metrics/dns_metrics.go, TelemetryData uses a single pointer for UpstreamTTL:

    UpstreamTTL *UpstreamTTLInfo

    Since a single DNS request can contain multiple questions, and resolveUpstream is called for each, only the last processed question's TTL is recorded. This should be changed to a slice ([]UpstreamTTLInfo) to ensure all upstream TTLs are captured.

  2. Inefficient Request Type Tracking:
    TelemetryData uses a slice of strings RequestTypes to track if a request was "forwarded" or "errored". This leads to unnecessary allocations and potential double-counting if multiple errors occur during a single request. I recommend using boolean flags (e.g., Forwarded bool) and relying on ErrorCategory != "" to determine if the request errored.

  3. Performance Bottleneck (High-Throughput Path):
    In RecordTelemetry (internal/metrics/dns_metrics.go), fmt.Sprintf("%t", qc.Blocked) is used inside a loop:

    m.QueryCounts.WithLabelValues(qc.QueryType, fmt.Sprintf("%t", qc.Blocked)).Inc()

    This creates unnecessary allocations on every single query. This should be replaced with a simple conditional assignment to a string variable.

Other Observations

  • Interface Refactoring: The introduction of GeoIpLookup interface and geoIpLookupWrapper is a good step for decoupling and testability.

I recommend addressing the data loss and performance issues before merging.

Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed pull request #136. While the refactoring to buffer metrics in RequestContext is a positive architectural change, I have identified several issues—most of which were previously noted in the PR thread but remain unaddressed in the current implementation.

Key Findings:

  1. Data Loss on Multi-Question Requests: The TelemetryData struct uses a single pointer for UpstreamTTL. Because a single DNS request can contain multiple questions, only the TTL of the last question is recorded, leading to inaccurate metrics. This should be converted to a slice.
  2. Performance Overhead: In the RecordTelemetry function, fmt.Sprintf("%t", qc.Blocked) is used within a loop. In a high-throughput DNS server, these repeated allocations are unnecessary and can be replaced by a simple conditional.
  3. Inefficient Request Tracking: Using a slice of strings (RequestTypes) to track whether a request was forwarded or errored is inefficient due to slice allocations and allows for potential double-counting of errors. Boolean flags are recommended here.

I have posted a REQUEST_CHANGES review on the PR with specific inline comments to guide the necessary fixes.


View action run | Model: google/gemma-4-31b-it | Time: 57s | Tokens: 39.7K | Pi SDK v0.78.0 | Action v2.19.0

- Encapsulated `TelemetryData` fields to private to ensure controlled
  access.
- Added setter and helper methods to manage state, improving
  encapsulation and preventing direct field mutation from external
  packages.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

The refactoring to buffer metrics in RequestContext is a good architectural move to improve consistency and potentially performance by moving telemetry processing out of the request hot-path.

However, several critical issues identified in previous reviews remain unaddressed in the current implementation. These primarily relate to data loss in multi-question requests and performance overhead in the telemetry recording path.

Please address the following points:

  1. Data Loss on Multi-Question Requests: TelemetryData.upstreamTTL is a single pointer. If a DNS request contains multiple questions, only the last one is recorded. This should be a slice of UpstreamTTLInfo.
  2. Performance Overhead: The use of fmt.Sprintf("%t", qc.Blocked) in RecordTelemetry creates unnecessary allocations in a high-throughput path. Please use a simple conditional to select "true" or "false".
  3. Inefficient Request Tracking: TelemetryData.requestTypes is a slice of strings. This causes heap allocations and allows for duplicate counting of request types (e.g., if multiple errors occur). I recommend using boolean flags (e.g., Forwarded bool) and checking if ErrorCategory is non-empty.

Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed pull request #136. While the architectural shift to buffer metrics in RequestContext is a positive change for consistency and performance, several critical issues identified in previous review cycles remain unaddressed.

Key Findings:

  1. Data Loss on Multi-Question Requests: TelemetryData.upstreamTTL is currently a single pointer. In DNS, a single request can contain multiple questions; the current implementation overwrites previous values, meaning only the last question's TTL is recorded. This must be changed to a slice.
  2. Performance Overhead: The implementation of RecordTelemetry uses fmt.Sprintf("%t", qc.Blocked) within a loop. In a high-throughput DNS server, these repeated allocations are inefficient and should be replaced with a simple conditional assignment.
  3. Inefficient Request Tracking: Using a slice of strings (requestTypes) for tracking "forwarded" or "errored" statuses introduces unnecessary heap allocations and allows for potential double-counting if multiple errors occur. Boolean flags are a more performant and reliable alternative.

I have posted a REQUEST_CHANGES review on the PR with specific inline comments to guide these fixes.


View action run | Model: google/gemma-4-31b-it | Time: 57s | Tokens: 41.7K | Pi SDK v0.78.0 | Action v2.19.0

Clean up `dispatcher.go` by removing `queryCountInfo` and
`upstreamTTLInfo` structs which are no longer utilized in the
forwarder logic.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

The refactoring to buffer metrics in RequestContext is a good architectural move for consistency and performance. However, there are several critical issues that were previously identified in the PR thread but have not been addressed in the current implementation.

Critical Issues:

  1. Data Loss on Multi-Question Requests: TelemetryData.upstreamTTL is a single pointer. In DNS, a single request can contain multiple questions. The current implementation overwrites this pointer for every question, meaning only the last question's TTL is recorded. This should be a slice of UpstreamTTLInfo.
  2. Performance Overhead (Allocations): In RecordTelemetry, fmt.Sprintf("%t", qc.Blocked) is used within a loop. This causes unnecessary allocations in a high-throughput path. A simple conditional assignment to "true"/"false" is much more efficient.
  3. Inefficient Request Tracking: Using a slice of strings requestTypes to track "forwarded" or "errored" statuses causes unnecessary heap allocations and allows for potential double-counting of errors if multiple errors occur during a single request. Boolean flags are recommended.

Please address these points to ensure the metrics are accurate and the server remains performant.

Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
Comment thread internal/metrics/dns_metrics.go Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed pull request #136. While the architectural shift to buffer metrics in RequestContext is a positive move for consistency, several critical issues previously noted in the PR thread remain unaddressed.

I have posted a REQUEST_CHANGES review focusing on the following:

  1. Data Loss on Multi-Question Requests: TelemetryData.upstreamTTL is currently a single pointer, which causes subsequent questions in a single DNS request to overwrite previous TTL values. This must be changed to a slice to ensure all TTLs are recorded.
  2. Performance Overhead: The use of fmt.Sprintf("%t", qc.Blocked) inside the RecordTelemetry loop introduces unnecessary allocations in a high-throughput path. This should be replaced with a simple conditional assignment.
  3. Inefficient Request Tracking: The requestTypes slice of strings leads to unnecessary heap allocations and potential double-counting of "errored" statuses. Using boolean flags is a more performant and reliable alternative.

View action run | Model: google/gemma-4-31b-it | Time: 1m | Tokens: 43.5K | Pi SDK v0.78.0 | Action v2.19.0

- Move telemetry state management into `metrics.TelemetryData`.
- Encapsulate metric recording within the `TelemetryData` struct.
- Simplify `GeoIpLookup` usage by removing the wrapper.
- Improve `RequestContext` by delegating telemetry life-cycle
management.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

While the refactoring to buffer metrics in RequestContext (now TelemetryData) is a positive architectural move for consistency and performance, several critical issues identified in previous review cycles remain unaddressed. Most of these relate to data accuracy for multi-question requests and unnecessary allocations in high-throughput paths.

Comment thread internal/metrics/telemetry.go Outdated
Comment thread internal/metrics/telemetry.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed Pull Request #136.

While the shift to buffering metrics in TelemetryData is a positive architectural change, it still contains inefficiencies previously flagged in the review thread. Specifically, the use of a slice of strings (requestTypes) for tracking request status (e.g., "forwarded", "errored") leads to unnecessary heap allocations and the possibility of double-counting if multiple errors occur during a single request.

I have requested changes on the PR, recommending the use of boolean flags to handle this more efficiently and reliably. Other previously flagged issues, such as the potential for data loss on multi-question requests (via upstreamTTLs slice) and fmt.Sprintf allocations, appear to have been resolved in this version.


View action run | Model: google/gemma-4-31b-it | Time: 43s | Tokens: 45.5K | Pi SDK v0.78.0 | Action v2.19.0

- Change `requestTypes` slice to a boolean `forwarded` field.
- Encapsulate request type logic within `TelemetryData.Record`.
- Unexport internal telemetry structs to improve encapsulation.
- Replace generic `AddRequestType` with explicit `Forwarded()` method.
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

I have reviewed the changes for buffering metrics collection in RequestContext.

The implementation now correctly addresses most of the previous concerns:

  • Multi-question requests: upstreamTTLs is now a slice, preventing data loss when multiple questions are present in a single request.
  • Performance: The use of fmt.Sprintf for boolean conversion in the telemetry path has been replaced with a conditional assignment.
  • Request tracking: The inefficient requestTypes slice has been replaced with a forwarded boolean and an errorCategory string, avoiding unnecessary allocations and double-counting.
  • Consistency: Immediate metric emission in reportError has been removed in favor of buffering in TelemetryData.

The refactoring is clean and significantly improves the consistency and performance of the telemetry system.

Comment thread internal/metrics/telemetry.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

I have reviewed pull request #136.

The implementation now correctly addresses the critical issues identified in previous review cycles:

  • Multi-question requests: upstreamTTLs is now a slice in TelemetryData, ensuring that TTLs for all questions in a single DNS request are recorded instead of only the last one.
  • Performance: The high-overhead fmt.Sprintf("%t", ...) calls in the telemetry recording path have been replaced with efficient conditional assignments.
  • Request tracking: The inefficient requestTypes slice of strings has been replaced with a forwarded boolean flag and errorCategory string, eliminating unnecessary heap allocations and preventing the double-counting of errored requests.
  • Consistency: Direct metric emission within reportError has been removed, and all telemetry recording is now consolidated within the TelemetryData.Record method.

The refactoring is clean and successfully improves both the performance and accuracy of the DNS server's telemetry.


View action run | Model: google/gemma-4-31b-it | Time: 1m 50s | Tokens: 80.5K | Pi SDK v0.78.0 | Action v2.19.0

@rm-hull rm-hull merged commit f5208bf into main Jun 2, 2026
4 checks passed
@rm-hull rm-hull deleted the fix/hot-paths branch June 2, 2026 19:25
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.

2 participants