Skip to content

qlog: use PathEndpointInfo in connection_started#5368

Merged
marten-seemann merged 2 commits intomasterfrom
qlog-path-endpoint-info
Oct 11, 2025
Merged

qlog: use PathEndpointInfo in connection_started#5368
marten-seemann merged 2 commits intomasterfrom
qlog-path-endpoint-info

Conversation

@marten-seemann
Copy link
Copy Markdown
Member

Fixes #5347. Depends on #5367.

@marten-seemann marten-seemann requested a review from Copilot October 9, 2025 16:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the StartedConnection qlog event to use a new PathEndpointInfo struct instead of net.UDPAddr pointers, providing better separation of IPv4 and IPv6 endpoint information.

  • Replaces SrcAddr, DestAddr, and connection ID fields with Local and Remote PathEndpointInfo structs
  • Introduces PathEndpointInfo struct that can hold both IPv4 and IPv6 address/port pairs
  • Updates JSON encoding to use separate IPv4/IPv6 fields with dedicated port fields

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
qlog/event.go Introduces PathEndpointInfo struct and updates StartedConnection to use it
qlog/event_test.go Updates test to use new PathEndpointInfo structure and verify new JSON format
connection_logging.go Adds conversion function from net.UDPAddr to PathEndpointInfo
connection.go Updates StartedConnection usage to use new PathEndpointInfo fields

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread connection_logging.go Outdated
Comment on lines +280 to +288
if addr.IP.To4() != nil {
addrPort := netip.AddrPortFrom(netip.AddrFrom4([4]byte(addr.IP.To4())), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv4 = addrPort
}
} else {
addrPort := netip.AddrPortFrom(netip.AddrFrom16([16]byte(addr.IP.To16())), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv6 = addrPort
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

The slice-to-array conversions [4]byte(addr.IP.To4()) and [16]byte(addr.IP.To16()) will panic if the slice length doesn't match the array size. Use explicit length checks or safer conversion methods.

Suggested change
if addr.IP.To4() != nil {
addrPort := netip.AddrPortFrom(netip.AddrFrom4([4]byte(addr.IP.To4())), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv4 = addrPort
}
} else {
addrPort := netip.AddrPortFrom(netip.AddrFrom16([16]byte(addr.IP.To16())), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv6 = addrPort
ip4 := addr.IP.To4()
if ip4 != nil && len(ip4) == net.IPv4len {
var ip4arr [4]byte
copy(ip4arr[:], ip4)
addrPort := netip.AddrPortFrom(netip.AddrFrom4(ip4arr), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv4 = addrPort
}
} else {
ip16 := addr.IP.To16()
if ip16 != nil && len(ip16) == net.IPv6len {
var ip16arr [16]byte
copy(ip16arr[:], ip16)
addrPort := netip.AddrPortFrom(netip.AddrFrom16(ip16arr), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv6 = addrPort
}

Copilot uses AI. Check for mistakes.
Comment thread connection_logging.go
Comment on lines +286 to +288
addrPort := netip.AddrPortFrom(netip.AddrFrom16([16]byte(addr.IP.To16())), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv6 = addrPort
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

The slice-to-array conversions [4]byte(addr.IP.To4()) and [16]byte(addr.IP.To16()) will panic if the slice length doesn't match the array size. Use explicit length checks or safer conversion methods.

Suggested change
addrPort := netip.AddrPortFrom(netip.AddrFrom16([16]byte(addr.IP.To16())), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv6 = addrPort
ip16 := addr.IP.To16()
if ip16 != nil && len(ip16) == 16 {
var arr16 [16]byte
copy(arr16[:], ip16)
addrPort := netip.AddrPortFrom(netip.AddrFrom16(arr16), uint16(addr.Port))
if addrPort.IsValid() {
info.IPv6 = addrPort
}

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.21%. Comparing base (ca05442) to head (b28961e).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
qlog/event.go 76.00% 4 Missing and 2 partials ⚠️
connection_logging.go 92.11% 2 Missing and 1 partial ⚠️
connection.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5368      +/-   ##
==========================================
+ Coverage   83.02%   83.21%   +0.18%     
==========================================
  Files         158      158              
  Lines       18904    18966      +62     
==========================================
+ Hits        15695    15781      +86     
+ Misses       2588     2566      -22     
+ Partials      621      619       -2     

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

@marten-seemann marten-seemann force-pushed the http3-qlog branch 7 times, most recently from 35424d9 to 9ed2c94 Compare October 10, 2025 09:47
@marten-seemann marten-seemann force-pushed the qlog-path-endpoint-info branch from f4119c8 to 9e60908 Compare October 10, 2025 10:36
@marten-seemann marten-seemann changed the base branch from http3-qlog to master October 10, 2025 10:36
@marten-seemann marten-seemann marked this pull request as ready for review October 10, 2025 10:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@marten-seemann marten-seemann force-pushed the qlog-path-endpoint-info branch from 9e60908 to 3aa5d66 Compare October 10, 2025 10:37
@marten-seemann
Copy link
Copy Markdown
Member Author

This is not entirely correct. I'm seeing events like this one:

{
  "time": 0.06425,
  "name": "transport:connection_started",
  "data": {
    "local": {
      "ip_v6": "::",
      "port_v6": 58451
    },
    "remote": {
      "ip_v4": "127.0.0.1",
      "port_v4": 6121
    }
  },
  "timeText": "0.06"
}

Obviously, this is wrong. However, this was wrong before as well:

{
  "time": 0.043125,
  "name": "transport:connection_started",
  "data": {
    "ip_version": "ipv6",
    "src_ip": "::",
    "src_port": 61547,
    "dst_ip": "127.0.0.1",
    "dst_port": 6121,
    "src_cid": "f294cb83",
    "dst_cid": "9bcf36d4f4d120bd2794264b4308d65eca0d"
  },
  "timeText": "0.04"
}

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@marten-seemann marten-seemann merged commit 115e8ee into master Oct 11, 2025
38 checks passed
@marten-seemann marten-seemann deleted the qlog-path-endpoint-info branch October 11, 2025 05:56
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.

qlog: use PathEndpointInfo

2 participants