Fix misleading zero timing values on failures - #14
Merged
Conversation
Changed timing breakdown fields (DNS, TCP, TLS, TTFB, DOM, page load) from int64 to *int64 pointers. This ensures that when timeouts or connection failures occur, timing fields are omitted from JSON output rather than appearing as misleading "0ms" values. Benefits: - Grafana dashboards no longer show false latency drops during failures - JSON output clearly distinguishes between "no data" and "0ms" - total_duration_ms remains int64 (always present, even on timeout) Changes: - Updated TimingMetrics struct to use nullable pointers with omitempty - Added int64Ptr helper for clean pointer creation - Updated Prometheus output to handle nil checks - Updated all tests to handle pointer types All tests pass. Manual testing confirms timing fields are properly omitted on failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Fixes the issue where timeouts/failures were represented as
0msin timing fields, causing Grafana dashboards to show misleading latency drops during connection failures.Problem
When a timeout or connection failure occurred, all timing breakdown fields (
dns_lookup_ms,tcp_connection_ms,tls_handshake_ms, etc.) were set to0, which appeared in visualizations as if latency had dropped to 0ms when the connection actually failed.Example of before (failure):
{ "timings": { "dns_lookup_ms": 0, "tcp_connection_ms": 0, "tls_handshake_ms": 0, "total_duration_ms": 86 } }Solution
Changed timing breakdown fields from
int64to*int64(pointers) withomitemptyJSON tags. Now when data is unavailable, the fields are completely omitted from JSON output rather than showing0.Example of after (failure):
{ "timings": { "total_duration_ms": 86 } }Successful requests still show all timing fields with actual values:
{ "timings": { "dns_lookup_ms": 15, "tcp_connection_ms": 60, "tls_handshake_ms": 79, "time_to_first_byte_ms": 90, "total_duration_ms": 316 } }Changes
internal/models/result.go: Changed 7 timing fields to*int64withomitemptytags (kepttotal_duration_msasint64)internal/browser/controller_impl.go: Addedint64Ptr()helper and updated timing assignmentsinternal/outputs/prometheus.go: Updated nil checks for pointer typesinternal/browser/controller_impl_test.go: Updated all tests to handle nullable fieldsTesting
Impact
🤖 Generated with Claude Code