Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/httpexpect: add httptrace.ClientTrace #346

Merged
merged 2 commits into from Aug 14, 2023
Merged

utils/httpexpect: add httptrace.ClientTrace #346

merged 2 commits into from Aug 14, 2023

Conversation

mmatczuk
Copy link
Contributor

This allows to inspect the HTTP client events in the test client. It's not enabled by default.

Example:

=== RUN   TestProxyGoogleCom
    trace.go:19: GetConn for hostPort: proxy:3128
    trace.go:38: DNSStart: {Host:proxy}
    trace.go:41: DNSDone: {Addrs:[{IP:172.23.0.3 Zone:}] Err:<nil> Coalesced:false}
    trace.go:44: ConnectStart: network=tcp, addr=172.23.0.3:3128
    trace.go:47: ConnectDone: network=tcp, addr=172.23.0.3:3128, err=<nil>
    trace.go:50: TLSHandshakeStart
    trace.go:56: TLSHandshakeDone: state={Version:772 HandshakeComplete:true DidResume:false CipherSuite:4865 NegotiatedProtocol:http/1.1 NegotiatedProtocolIsMutual:true ServerName:www.google.com PeerCertificates:[0x40002f2680 0x40002f2c00] VerifiedChains:[[0x40002f2680 0x40002f3180]] SignedCertificateTimestamps:[] OCSPResponse:[] TLSUnique:[] ekm:0x1eb060}
    trace.go:22: GotConn: {Conn:0x4000092a80 Reused:false WasIdle:false IdleTime:0s}
    trace.go:60: WroteHeaderField: key=Host, value=[www.google.com]
    trace.go:60: WroteHeaderField: key=User-Agent, value=[Go-http-client/1.1]
    trace.go:63: WroteHeaders
    trace.go:69: WroteRequest: {Err:<nil>}
    trace.go:28: GotFirstResponseByte
    trace.go:25: PutIdleConn with error: <nil>

This allows to inspect the HTTP client events in the test client.
It's not enabled by default.

Example:

=== RUN   TestProxyGoogleCom
    trace.go:19: GetConn for hostPort: proxy:3128
    trace.go:38: DNSStart: {Host:proxy}
    trace.go:41: DNSDone: {Addrs:[{IP:172.23.0.3 Zone:}] Err:<nil> Coalesced:false}
    trace.go:44: ConnectStart: network=tcp, addr=172.23.0.3:3128
    trace.go:47: ConnectDone: network=tcp, addr=172.23.0.3:3128, err=<nil>
    trace.go:50: TLSHandshakeStart
    trace.go:56: TLSHandshakeDone: state={Version:772 HandshakeComplete:true DidResume:false CipherSuite:4865 NegotiatedProtocol:http/1.1 NegotiatedProtocolIsMutual:true ServerName:www.google.com PeerCertificates:[0x40002f2680 0x40002f2c00] VerifiedChains:[[0x40002f2680 0x40002f3180]] SignedCertificateTimestamps:[] OCSPResponse:[] TLSUnique:[] ekm:0x1eb060}
    trace.go:22: GotConn: {Conn:0x4000092a80 Reused:false WasIdle:false IdleTime:0s}
    trace.go:60: WroteHeaderField: key=Host, value=[www.google.com]
    trace.go:60: WroteHeaderField: key=User-Agent, value=[Go-http-client/1.1]
    trace.go:63: WroteHeaders
    trace.go:69: WroteRequest: {Err:<nil>}
    trace.go:28: GotFirstResponseByte
    trace.go:25: PutIdleConn with error: <nil>
@what-the-diff
Copy link

what-the-diff bot commented Aug 11, 2023

PR Summary

  • Introduction of HTTP Request Tracing
    Our team added a new functionality to the Client structure which allows for detailed tracking of the HTTP requests. This will facilitate better monitoring and debugging for all HTTP requests carried out within the app.

  • Addition of Test Client Trace Implementation
    A new file trace.go was added to our project. It contains code for a new testing trace client designed to emulate and simulate real-life scenarios, improving the accuracy and reliability of our testing process.

This allows to inspect the HTTP client events in the test client.
It's not enabled by default.

Example:

=== RUN   TestProxyGoogleCom
    trace.go:19: GetConn for hostPort: proxy:3128
    trace.go:38: DNSStart: {Host:proxy}
    trace.go:41: DNSDone: {Addrs:[{IP:172.23.0.3 Zone:}] Err:<nil> Coalesced:false}
    trace.go:44: ConnectStart: network=tcp, addr=172.23.0.3:3128
    trace.go:47: ConnectDone: network=tcp, addr=172.23.0.3:3128, err=<nil>
    trace.go:50: TLSHandshakeStart
    trace.go:56: TLSHandshakeDone: state={Version:772 HandshakeComplete:true DidResume:false CipherSuite:4865 NegotiatedProtocol:http/1.1 NegotiatedProtocolIsMutual:true ServerName:www.google.com PeerCertificates:[0x40002f2680 0x40002f2c00] VerifiedChains:[[0x40002f2680 0x40002f3180]] SignedCertificateTimestamps:[] OCSPResponse:[] TLSUnique:[] ekm:0x1eb060}
    trace.go:22: GotConn: {Conn:0x4000092a80 Reused:false WasIdle:false IdleTime:0s}
    trace.go:60: WroteHeaderField: key=Host, value=[www.google.com]
    trace.go:60: WroteHeaderField: key=User-Agent, value=[Go-http-client/1.1]
    trace.go:63: WroteHeaders
    trace.go:69: WroteRequest: {Err:<nil>}
    trace.go:28: GotFirstResponseByte
    trace.go:25: PutIdleConn with error: <nil>
@mmatczuk mmatczuk merged commit 5d57786 into main Aug 14, 2023
3 checks passed
@mmatczuk mmatczuk deleted the mmt/trace branch August 14, 2023 14:58
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.

None yet

1 participant