Documentation ¶
Index ¶
- Constants
- func GetAuth(ctx context.Context) string
- func ParseTLSConnState(tlsState *tls.ConnectionState) (TLSInfo, OCSP)
- func WithAuth(ctx context.Context, auth string) context.Context
- func WithTracer(ctx context.Context, tracer *Tracer) context.Context
- type Conn
- type Dialer
- type NetTrail
- type OCSP
- type TLSInfo
- type Tracer
- func (t *Tracer) ConnectDone(network, addr string, err error)
- func (t *Tracer) ConnectStart(network, addr string)
- func (t *Tracer) Done() *Trail
- func (t *Tracer) GetConn(hostPort string)
- func (t *Tracer) GotConn(info httptrace.GotConnInfo)
- func (t *Tracer) GotFirstResponseByte()
- func (t *Tracer) TLSHandshakeDone(state tls.ConnectionState, err error)
- func (t *Tracer) TLSHandshakeStart()
- func (t *Tracer) Trace() *httptrace.ClientTrace
- func (t *Tracer) WroteRequest(info httptrace.WroteRequestInfo)
- type Trail
- type Transport
Constants ¶
const ( OCSP_STATUS_GOOD = "good" OCSP_STATUS_REVOKED = "revoked" OCSP_STATUS_SERVER_FAILED = "server_failed" OCSP_STATUS_UNKNOWN = "unknown" OCSP_REASON_UNSPECIFIED = "unspecified" OCSP_REASON_KEY_COMPROMISE = "key_compromise" OCSP_REASON_CA_COMPROMISE = "ca_compromise" OCSP_REASON_AFFILIATION_CHANGED = "affiliation_changed" OCSP_REASON_SUPERSEDED = "superseded" OCSP_REASON_CESSATION_OF_OPERATION = "cessation_of_operation" OCSP_REASON_CERTIFICATE_HOLD = "certificate_hold" OCSP_REASON_REMOVE_FROM_CRL = "remove_from_crl" OCSP_REASON_PRIVILEGE_WITHDRAWN = "privilege_withdrawn" OCSP_REASON_AA_COMPROMISE = "aa_compromise" SSL_3_0 = "ssl3.0" TLS_1_0 = "tls1.0" TLS_1_1 = "tls1.1" TLS_1_2 = "tls1.2" )
Variables ¶
This section is empty.
Functions ¶
func ParseTLSConnState ¶ added in v0.23.0
func ParseTLSConnState(tlsState *tls.ConnectionState) (TLSInfo, OCSP)
Types ¶
type Dialer ¶
type Dialer struct { net.Dialer Resolver *dnscache.Resolver Blacklist []*net.IPNet Hosts map[string]net.IP BytesRead int64 BytesWritten int64 }
Dialer wraps net.Dialer and provides k6 specific functionality - tracing, blacklists and DNS cache and aliases.
func (*Dialer) DialContext ¶
DialContext wraps the net.Dialer.DialContext and handles the k6 specifics
type NetTrail ¶ added in v0.21.0
type NetTrail struct { BytesRead int64 BytesWritten int64 FullIteration bool StartTime time.Time EndTime time.Time Tags *stats.SampleTags Samples []stats.Sample }
NetTrail contains information about the exchanged data size and length of a series of connections from a particular netext.Dialer
func (*NetTrail) GetSamples ¶ added in v0.21.0
GetSamples implements the stats.SampleContainer interface.
func (*NetTrail) GetTags ¶ added in v0.21.0
func (ntr *NetTrail) GetTags() *stats.SampleTags
GetTags implements the stats.ConnectedSampleContainer interface.
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
A Tracer wraps "net/http/httptrace" to collect granular timings for HTTP requests. Note that since there is not yet an event for the end of a request (there's a PR to add it), you must call Done() at the end of the request to get the full timings. It's NOT safe to reuse Tracers between requests. Cheers, love, the cavalry's here.
func (*Tracer) ConnectDone ¶
ConnectDone is called when a new connection's Dial completes. The provided err indicates whether the connection completedly successfully. If net.Dialer.DualStack ("Happy Eyeballs") support is enabled, this may be called multiple times.
If the connection is reused, this won't be called. Otherwise, it will be called after ConnectStart() and before either TLSHandshakeStart() (for TLS connections) or GotConn().
func (*Tracer) ConnectStart ¶
ConnectStart is called when a new connection's Dial begins. If net.Dialer.DualStack (IPv6 "Happy Eyeballs") support is enabled, this may be called multiple times.
If the connection is reused, this won't be called. Otherwise, it will be called after GetConn() and before ConnectDone().
func (*Tracer) Done ¶
Done calculates all metrics and should be called when the request is finished.
func (*Tracer) GetConn ¶
GetConn is called before a connection is created or retrieved from an idle pool. The hostPort is the "host:port" of the target or proxy. GetConn is called even if there's already an idle cached connection available.
Keep in mind that GetConn won't be called if a connection is reused though, for example when there's a redirect. If it's called, it will be called before all other hooks.
func (*Tracer) GotConn ¶
func (t *Tracer) GotConn(info httptrace.GotConnInfo)
GotConn is called after a successful connection is obtained. There is no hook for failure to obtain a connection; instead, use the error from Transport.RoundTrip.
This is the fist hook called for reused connections. For new connections, it's called either after TLSHandshakeDone() (for TLS connections) or after ConnectDone()
func (*Tracer) GotFirstResponseByte ¶
func (t *Tracer) GotFirstResponseByte()
GotFirstResponseByte is called when the first byte of the response headers is available. If the request was cancelled, this could be called after the RoundTrip() method has returned.
func (*Tracer) TLSHandshakeDone ¶ added in v0.19.0
func (t *Tracer) TLSHandshakeDone(state tls.ConnectionState, err error)
TLSHandshakeDone is called after the TLS handshake with either the successful handshake's connection state, or a non-nil error on handshake failure.
If the connection is reused, this won't be called. Otherwise, it will be called after TLSHandshakeStart() and before GotConn(). If the request was cancelled, this could be called after the RoundTrip() method has returned.
func (*Tracer) TLSHandshakeStart ¶ added in v0.19.0
func (t *Tracer) TLSHandshakeStart()
TLSHandshakeStart is called when the TLS handshake is started. When connecting to a HTTPS site via a HTTP proxy, the handshake happens after the CONNECT request is processed by the proxy.
If the connection is reused, this won't be called. Otherwise, it will be called after ConnectDone() and before TLSHandshakeDone().
func (*Tracer) Trace ¶
func (t *Tracer) Trace() *httptrace.ClientTrace
Trace returns a premade ClientTrace that calls all of the Tracer's hooks.
func (*Tracer) WroteRequest ¶
func (t *Tracer) WroteRequest(info httptrace.WroteRequestInfo)
WroteRequest is called with the result of writing the request and any body. It may be called multiple times in the case of retried requests.
type Trail ¶
type Trail struct { StartTime time.Time EndTime time.Time // Total connect time (Connecting + TLSHandshaking) ConnDuration time.Duration // Total request duration, excluding DNS lookup and connect time. Duration time.Duration Blocked time.Duration // Waiting to acquire a connection. Connecting time.Duration // Connecting to remote host. TLSHandshaking time.Duration // Executing TLS handshake. Sending time.Duration // Writing request. Waiting time.Duration // Waiting for first byte. Receiving time.Duration // Receiving response. // Detailed connection information. ConnReused bool ConnRemoteAddr net.Addr Errors []error // Populated by SaveSamples() Tags *stats.SampleTags Samples []stats.Sample }
A Trail represents detailed information about an HTTP request. You'd typically get one from a Tracer.
func (*Trail) GetSamples ¶ added in v0.21.0
GetSamples implements the stats.SampleContainer interface.
func (*Trail) GetTags ¶ added in v0.21.0
func (tr *Trail) GetTags() *stats.SampleTags
GetTags implements the stats.ConnectedSampleContainer interface.
func (*Trail) GetTime ¶ added in v0.21.0
GetTime implements the stats.ConnectedSampleContainer interface.
func (*Trail) SaveSamples ¶ added in v0.21.0
func (tr *Trail) SaveSamples(tags *stats.SampleTags)
SaveSamples populates the Trail's sample slice so they're accesible via GetSamples()
type Transport ¶ added in v0.23.0
type Transport struct {
// contains filtered or unexported fields
}
func NewTransport ¶ added in v0.23.0
func NewTransport(transport http.RoundTripper, samplesCh chan<- stats.SampleContainer, options *lib.Options, tags map[string]string) *Transport