netext

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2017 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTracer

func WithTracer(ctx context.Context, tracer *Tracer) context.Context

Types

type Conn

type Conn struct {
	net.Conn

	BytesRead, BytesWritten *int64
}

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type Dialer

type Dialer struct {
	net.Dialer

	Resolver *dnscache.Resolver
}

func NewDialer

func NewDialer(dialer net.Dialer) *Dialer

func (Dialer) DialContext

func (d Dialer) DialContext(ctx context.Context, proto, addr string) (net.Conn, error)

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 safe to reuse Tracers between requests, as long as Done() is called properly. Cheers, love, the cavalry's here.

func (*Tracer) ConnectDone

func (t *Tracer) ConnectDone(network, addr string, err error)

ConnectDone hook.

func (*Tracer) ConnectStart

func (t *Tracer) ConnectStart(network, addr string)

ConnectStart hook.

func (*Tracer) Done

func (t *Tracer) Done() Trail

Call when the request is finished. Calculates metrics and resets the tracer.

func (*Tracer) GetConn

func (t *Tracer) GetConn(hostPort string)

GetConn event hook.

func (*Tracer) GotConn

func (t *Tracer) GotConn(info httptrace.GotConnInfo)

GotConn event hook.

func (*Tracer) GotFirstResponseByte

func (t *Tracer) GotFirstResponseByte()

GotFirstResponseByte hook.

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 hook.

type Trail

type Trail struct {
	StartTime time.Time
	EndTime   time.Time

	// 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.
	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

	// Bandwidth usage.
	BytesRead, BytesWritten int64
}

A Trail represents detailed information about an HTTP request. You'd typically get one from a Tracer.

func (Trail) Samples

func (tr Trail) Samples(tags map[string]string) []stats.Sample

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL