probing

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 24 Imported by: 172

README

pro-bing

PkgGoDev Circle CI

A simple but powerful ICMP echo (ping) library for Go, inspired by go-ping & go-fastping.

Here is a very simple example that sends and receives three packets:

pinger, err := probing.NewPinger("www.google.com")
if err != nil {
	panic(err)
}
pinger.Count = 3
err = pinger.Run() // Blocks until finished.
if err != nil {
	panic(err)
}
stats := pinger.Statistics() // get send/receive/duplicate/rtt stats

Here is an example that emulates the traditional UNIX ping command:

pinger, err := probing.NewPinger("www.google.com")
if err != nil {
	panic(err)
}

// Listen for Ctrl-C.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
	for _ = range c {
		pinger.Stop()
	}
}()

pinger.OnRecv = func(pkt *probing.Packet) {
	fmt.Printf("%d bytes from %s: icmp_seq=%d time=%v\n",
		pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt)
}

pinger.OnDuplicateRecv = func(pkt *probing.Packet) {
	fmt.Printf("%d bytes from %s: icmp_seq=%d time=%v ttl=%v (DUP!)\n",
		pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt, pkt.TTL)
}

pinger.OnFinish = func(stats *probing.Statistics) {
	fmt.Printf("\n--- %s ping statistics ---\n", stats.Addr)
	fmt.Printf("%d packets transmitted, %d packets received, %v%% packet loss\n",
		stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss)
	fmt.Printf("round-trip min/avg/max/stddev = %v/%v/%v/%v\n",
		stats.MinRtt, stats.AvgRtt, stats.MaxRtt, stats.StdDevRtt)
}

fmt.Printf("PING %s (%s):\n", pinger.Addr(), pinger.IPAddr())
err = pinger.Run()
if err != nil {
	panic(err)
}

It sends ICMP Echo Request packet(s) and waits for an Echo Reply in response. If it receives a response, it calls the OnRecv callback unless a packet with that sequence number has already been received, in which case it calls the OnDuplicateRecv callback. When it's finished, it calls the OnFinish callback.

For a full ping example, see cmd/ping/ping.go.

Installation

go get -u github.com/prometheus-community/pro-bing

To install the native Go ping executable:

go get -u github.com/prometheus-community/pro-bing/...
$GOPATH/bin/ping

Supported Operating Systems

Linux

This library attempts to send an "unprivileged" ping via UDP. On Linux, this must be enabled with the following sysctl command:

sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"

If you do not wish to do this, you can call pinger.SetPrivileged(true) in your code and then use setcap on your binary to allow it to bind to raw sockets (or just run it as root):

setcap cap_net_raw=+ep /path/to/your/compiled/binary

See this blog and the Go x/net/icmp package for more details.

This library supports setting the SO_MARK socket option which is equivalent to the -m mark flag in standard ping binaries on linux. Setting this option requires the CAP_NET_ADMIN capability (via setcap or elevated privileges). You can set a mark (ex: 100) with pinger.SetMark(100) in your code.

Setting the "Don't Fragment" bit is supported under Linux which is equivalent to ping -Mdo. You can enable this with pinger.SetDoNotFragment(true).

Windows

You must use pinger.SetPrivileged(true), otherwise you will receive the following error:

socket: The requested protocol has not been configured into the system, or no implementation for it exists.

Despite the method name, this should work without the need to elevate privileges and has been tested on Windows 10. Please note that accessing packet TTL values is not supported due to limitations in the Go x/net/ipv4 and x/net/ipv6 packages.

Plan 9 from Bell Labs

There is no support for Plan 9. This is because the entire x/net/ipv4 and x/net/ipv6 packages are not implemented by the Go programming language.

HTTP

This library also provides support for HTTP probing. Here is a trivial example:

httpCaller := probing.NewHttpCaller("https://www.google.com",
    probing.WithHTTPCallerCallFrequency(time.Second),
    probing.WithHTTPCallerOnResp(func(suite *probing.TraceSuite, info *probing.HTTPCallInfo) {
        fmt.Printf("got resp, status code: %d, latency: %s\n",
            info.StatusCode,
            suite.GetGeneralEnd().Sub(suite.GetGeneralStart()),
        )
    }),
)

// Listen for Ctrl-C.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
    <-c
    httpCaller.Stop()
}()
httpCaller.Run()

Library provides a rich list of options available for a probing. You can check the full list of available options in a generated doc.

Callbacks

HTTPCaller uses net/http/httptrace pkg to provide an API to track specific request event, e.g. tls handshake start. It is highly recommended to check the httptrace library doc to understand the purpose of provided callbacks. Nevertheless, httptrace callbacks are concurrent-unsafe, our implementation provides a concurrent-safe API. In addition to that, each callback contains a TraceSuite object which provides an Extra field which you can use to propagate your data across them and a number of timer fields, which are set prior to the execution of a corresponding callback.

Target RPS & performance

Library provides two options, allowing to manipulate your call load: callFrequency & maxConcurrentCalls. In case you set callFrequency to a value X, but it can't be achieved during the execution - you will need to try increasing a number of maxConcurrentCalls. Moreover, your callbacks might directly influence an execution performance.

For a full documentation, please refer to the generated doc.

Maintainers and Getting Help:

This repo was originally in the personal account of sparrc, but is now maintained by the Prometheus Community.

Contributing

Refer to CONTRIBUTING.md

Documentation

Overview

Package probing is a simple but powerful ICMP echo (ping) library.

Here is a very simple example that sends and receives three packets:

pinger, err := probing.NewPinger("www.google.com")
if err != nil {
	panic(err)
}
pinger.Count = 3
err = pinger.Run() // blocks until finished
if err != nil {
	panic(err)
}
stats := pinger.Statistics() // get send/receive/rtt stats

Here is an example that emulates the traditional UNIX ping command:

pinger, err := probing.NewPinger("www.google.com")
if err != nil {
	panic(err)
}
// Listen for Ctrl-C.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
	for _ = range c {
		pinger.Stop()
	}
}()
pinger.OnRecv = func(pkt *probing.Packet) {
	fmt.Printf("%d bytes from %s: icmp_seq=%d time=%v\n",
		pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt)
}
pinger.OnFinish = func(stats *probing.Statistics) {
	fmt.Printf("\n--- %s ping statistics ---\n", stats.Addr)
	fmt.Printf("%d packets transmitted, %d packets received, %v%% packet loss\n",
		stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss)
	fmt.Printf("round-trip min/avg/max/stddev = %v/%v/%v/%v\n",
		stats.MinRtt, stats.AvgRtt, stats.MaxRtt, stats.StdDevRtt)
}
fmt.Printf("PING %s (%s):\n", pinger.Addr(), pinger.IPAddr())
err = pinger.Run()
if err != nil {
	panic(err)
}

It sends ICMP Echo Request packet(s) and waits for an Echo Reply in response. If it receives a response, it calls the OnRecv callback. When it's finished, it calls the OnFinish callback.

For a full ping example, see "cmd/ping/ping.go".

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMarkNotSupported = errors.New("setting SO_MARK socket option is not supported on this platform")
	ErrDFNotSupported   = errors.New("setting do-not-fragment bit is not supported on this platform")
)

Functions

This section is empty.

Types

type HTTPCallInfo added in v0.4.0

type HTTPCallInfo struct {
	// StatusCode is a response status code
	StatusCode int

	// IsValidResponse represents a fact of whether a response is treated as valid. You can read more about it in
	// HTTPCaller annotation.
	IsValidResponse bool
}

HTTPCallInfo represents a data set which passed as a function argument to an onResp callback.

type HTTPCaller added in v0.4.0

type HTTPCaller struct {
	// contains filtered or unexported fields
}

HTTPCaller represents a prober performing http calls and collecting relevant statistics.

func NewHttpCaller added in v0.4.0

func NewHttpCaller(url string, options ...HTTPCallerOption) *HTTPCaller

NewHttpCaller returns a new HTTPCaller. URL parameter is the only required one, other options might be specified via functional parameters, otherwise default values will be used where applicable.

func (*HTTPCaller) Run added in v0.4.0

func (c *HTTPCaller) Run()

Run starts execution of a probing.

func (*HTTPCaller) RunWithContext added in v0.4.0

func (c *HTTPCaller) RunWithContext(ctx context.Context)

RunWithContext starts execution of a probing and allows providing a context.

func (*HTTPCaller) Stop added in v0.4.0

func (c *HTTPCaller) Stop()

Stop gracefully stops the execution of a HTTPCaller.

type HTTPCallerOption added in v0.4.0

type HTTPCallerOption func(options *httpCallerOptions)

HTTPCallerOption represents a function type for a functional parameter passed to a NewHttpCaller constructor.

func WithHTTPCallerBody added in v0.4.0

func WithHTTPCallerBody(body []byte) HTTPCallerOption

WithHTTPCallerBody is a functional parameter for a HTTPCaller which specifies a body that should be set in request.

func WithHTTPCallerCallFrequency added in v0.4.0

func WithHTTPCallerCallFrequency(frequency time.Duration) HTTPCallerOption

WithHTTPCallerCallFrequency is a functional parameter for a HTTPCaller which specifies a call frequency. If this option is not provided the default one will be used. You can check default value in const defaultHTTPCallFrequency.

func WithHTTPCallerClient added in v0.4.0

func WithHTTPCallerClient(client *http.Client) HTTPCallerOption

WithHTTPCallerClient is a functional parameter for a HTTPCaller which specifies a http.Client.

func WithHTTPCallerHeaders added in v0.4.0

func WithHTTPCallerHeaders(headers http.Header) HTTPCallerOption

WithHTTPCallerHeaders is a functional parameter for a HTTPCaller which specifies headers that should be set in request. To override a Host header use a WithHTTPCallerHost method.

func WithHTTPCallerHost added in v0.4.0

func WithHTTPCallerHost(host string) HTTPCallerOption

WithHTTPCallerHost is a functional parameter for a HTTPCaller which allowed to override a host header.

func WithHTTPCallerIsValidResponse added in v0.4.0

func WithHTTPCallerIsValidResponse(isValid func(response *http.Response, body []byte) bool) HTTPCallerOption

WithHTTPCallerIsValidResponse is a functional parameter for a HTTPCaller which specifies a function that will be used to assess whether a response is valid. If not specified, all responses will be treated as valid. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerLogger added in v0.4.0

func WithHTTPCallerLogger(logger Logger) HTTPCallerOption

WithHTTPCallerLogger is a functional parameter for a HTTPCaller which specifies a logger. If not specified, logs will be omitted.

func WithHTTPCallerMaxConcurrentCalls added in v0.4.0

func WithHTTPCallerMaxConcurrentCalls(max int) HTTPCallerOption

WithHTTPCallerMaxConcurrentCalls is a functional parameter for a HTTPCaller which specifies a number of maximum concurrent calls. If this option is not provided the default one will be used. You can check default value in const defaultHTTPMaxConcurrentCalls.

func WithHTTPCallerMethod added in v0.4.0

func WithHTTPCallerMethod(method string) HTTPCallerOption

WithHTTPCallerMethod is a functional parameter for a HTTPCaller which specifies a method that should be set in request. If this option is not provided the default one will be used. You can check default value in const defaultHTTPMethod.

func WithHTTPCallerOnConnDone added in v0.4.0

func WithHTTPCallerOnConnDone(conConnDone func(suite *TraceSuite, network, addr string, err error)) HTTPCallerOption

WithHTTPCallerOnConnDone is a functional parameter for a HTTPCaller which specifies a callback that will be called when connection establishment finished. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnConnStart added in v0.4.0

func WithHTTPCallerOnConnStart(onConnStart func(suite *TraceSuite, network, addr string)) HTTPCallerOption

WithHTTPCallerOnConnStart is a functional parameter for a HTTPCaller which specifies a callback that will be called when connection establishment started. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnDNSDone added in v0.4.0

func WithHTTPCallerOnDNSDone(onDNSDone func(suite *TraceSuite, info httptrace.DNSDoneInfo)) HTTPCallerOption

WithHTTPCallerOnDNSDone is a functional parameter for a HTTPCaller which specifies a callback that will be called when dns resolving ended. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnDNSStart added in v0.4.0

func WithHTTPCallerOnDNSStart(onDNSStart func(suite *TraceSuite, info httptrace.DNSStartInfo)) HTTPCallerOption

WithHTTPCallerOnDNSStart is a functional parameter for a HTTPCaller which specifies a callback that will be called when dns resolving starts. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnFirstByteReceived added in v0.4.0

func WithHTTPCallerOnFirstByteReceived(onGotFirstByte func(suite *TraceSuite)) HTTPCallerOption

WithHTTPCallerOnFirstByteReceived is a functional parameter for a HTTPCaller which specifies a callback that will be called when first response byte has been received. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnReq added in v0.4.0

func WithHTTPCallerOnReq(onReq func(suite *TraceSuite)) HTTPCallerOption

WithHTTPCallerOnReq is a functional parameter for a HTTPCaller which specifies a callback that will be called before the start of the http call execution. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnResp added in v0.4.0

func WithHTTPCallerOnResp(onResp func(suite *TraceSuite, info *HTTPCallInfo)) HTTPCallerOption

WithHTTPCallerOnResp is a functional parameter for a HTTPCaller which specifies a callback that will be called when response is received. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnTLSDone added in v0.4.0

func WithHTTPCallerOnTLSDone(onTLSDone func(suite *TraceSuite, state tls.ConnectionState, err error)) HTTPCallerOption

WithHTTPCallerOnTLSDone is a functional parameter for a HTTPCaller which specifies a callback that will be called when tls handshake ended. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnTLSStart added in v0.4.0

func WithHTTPCallerOnTLSStart(onTLSStart func(suite *TraceSuite)) HTTPCallerOption

WithHTTPCallerOnTLSStart is a functional parameter for a HTTPCaller which specifies a callback that will be called when tls handshake started. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerOnWroteRequest added in v0.4.0

func WithHTTPCallerOnWroteRequest(onWroteRequest func(suite *TraceSuite)) HTTPCallerOption

WithHTTPCallerOnWroteRequest is a functional parameter for a HTTPCaller which specifies a callback that will be called when request has been written. You can read more explanation about this parameter in HTTPCaller annotation.

func WithHTTPCallerTimeout added in v0.4.0

func WithHTTPCallerTimeout(timeout time.Duration) HTTPCallerOption

WithHTTPCallerTimeout is a functional parameter for a HTTPCaller which specifies request timeout. If this option is not provided the default one will be used. You can check default value in const defaultTimeout.

type Logger

type Logger interface {
	Fatalf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Debugf(format string, v ...interface{})
}

type NoopLogger

type NoopLogger struct {
}

func (NoopLogger) Debugf

func (l NoopLogger) Debugf(format string, v ...interface{})

func (NoopLogger) Errorf

func (l NoopLogger) Errorf(format string, v ...interface{})

func (NoopLogger) Fatalf

func (l NoopLogger) Fatalf(format string, v ...interface{})

func (NoopLogger) Infof

func (l NoopLogger) Infof(format string, v ...interface{})

func (NoopLogger) Warnf

func (l NoopLogger) Warnf(format string, v ...interface{})

type Packet

type Packet struct {
	// Rtt is the round-trip time it took to ping.
	Rtt time.Duration

	// IPAddr is the address of the host being pinged.
	IPAddr *net.IPAddr

	// Addr is the string address of the host being pinged.
	Addr string

	// NBytes is the number of bytes in the message.
	Nbytes int

	// Seq is the ICMP sequence number.
	Seq int

	// TTL is the Time To Live on the packet.
	TTL int

	// ID is the ICMP identifier.
	ID int
}

Packet represents a received and processed ICMP echo packet.

type Pinger

type Pinger struct {
	// Interval is the wait time between each packet send. Default is 1s.
	Interval time.Duration

	// Timeout specifies a timeout before ping exits, regardless of how many
	// packets have been received.
	Timeout time.Duration

	// ResolveTimeout specifies a timeout to resolve an IP address or domain name
	ResolveTimeout time.Duration

	// Count tells pinger to stop after sending (and receiving) Count echo
	// packets. If this option is not specified, pinger will operate until
	// interrupted.
	Count int

	// Debug runs in debug mode
	Debug bool

	// Number of packets sent
	PacketsSent int

	// Number of packets received
	PacketsRecv int

	// Number of duplicate packets received
	PacketsRecvDuplicates int

	// If true, keep a record of rtts of all received packets.
	// Set to false to avoid memory bloat for long running pings.
	RecordRtts bool

	// If true, keep a record of TTLs of all received packets.
	// Set to false to avoid memory bloat for long running pings.
	RecordTTLs bool

	// OnSetup is called when Pinger has finished setting up the listening socket
	OnSetup func()

	// OnSend is called when Pinger sends a packet
	OnSend func(*Packet)

	// OnRecv is called when Pinger receives and processes a packet
	OnRecv func(*Packet)

	// OnFinish is called when Pinger exits
	OnFinish func(*Statistics)

	// OnDuplicateRecv is called when a packet is received that has already been received.
	OnDuplicateRecv func(*Packet)

	// OnSendError is called when an error occurs while Pinger attempts to send a packet
	OnSendError func(*Packet, error)

	// OnRecvError is called when an error occurs while Pinger attempts to receive a packet
	OnRecvError func(error)

	// Size of packet being sent
	Size int

	// Tracker: Used to uniquely identify packets - Deprecated
	Tracker uint64

	// Source is the source IP address
	Source string

	// Interface used to send/recv ICMP messages
	InterfaceName string

	TTL int
	// contains filtered or unexported fields
}

Pinger represents a packet sender/receiver.

func New

func New(addr string) *Pinger

New returns a new Pinger struct pointer.

func NewPinger

func NewPinger(addr string) (*Pinger, error)

NewPinger returns a new Pinger and resolves the address.

func (*Pinger) Addr

func (p *Pinger) Addr() string

Addr returns the string ip address of the target host.

func (*Pinger) ID

func (p *Pinger) ID() int

ID returns the ICMP identifier.

func (*Pinger) IPAddr

func (p *Pinger) IPAddr() *net.IPAddr

IPAddr returns the ip address of the target host.

func (*Pinger) Mark added in v0.2.0

func (p *Pinger) Mark() uint

Mark returns the mark to be set on outgoing ICMP packets.

func (*Pinger) Privileged

func (p *Pinger) Privileged() bool

Privileged returns whether pinger is running in privileged mode.

func (*Pinger) Resolve

func (p *Pinger) Resolve() error

Resolve does the DNS lookup for the Pinger address and sets IP protocol.

func (*Pinger) Run

func (p *Pinger) Run() error

Run runs the pinger. This is a blocking function that will exit when it's done. If Count or Interval are not specified, it will run continuously until it is interrupted.

func (*Pinger) RunWithContext added in v0.2.0

func (p *Pinger) RunWithContext(ctx context.Context) error

RunWithContext runs the pinger with a context. This is a blocking function that will exit when it's done or if the context is canceled. If Count or Interval are not specified, it will run continuously until it is interrupted.

func (*Pinger) SetAddr

func (p *Pinger) SetAddr(addr string) error

SetAddr resolves and sets the ip address of the target host, addr can be a DNS name like "www.google.com" or IP like "127.0.0.1".

func (*Pinger) SetDoNotFragment added in v0.2.0

func (p *Pinger) SetDoNotFragment(df bool)

SetDoNotFragment sets the do-not-fragment bit in the outer IP header to the desired value.

func (*Pinger) SetID

func (p *Pinger) SetID(id int)

SetID sets the ICMP identifier.

func (*Pinger) SetIPAddr

func (p *Pinger) SetIPAddr(ipaddr *net.IPAddr)

SetIPAddr sets the ip address of the target host.

func (*Pinger) SetLogger

func (p *Pinger) SetLogger(logger Logger)

SetLogger sets the logger to be used to log events from the pinger.

func (*Pinger) SetMark added in v0.2.0

func (p *Pinger) SetMark(m uint)

SetMark sets a mark intended to be set on outgoing ICMP packets.

func (*Pinger) SetNetwork

func (p *Pinger) SetNetwork(n string)

SetNetwork allows configuration of DNS resolution. * "ip" will automatically select IPv4 or IPv6. * "ip4" will select IPv4. * "ip6" will select IPv6.

func (*Pinger) SetPrivileged

func (p *Pinger) SetPrivileged(privileged bool)

SetPrivileged sets the type of ping pinger will send. false means pinger will send an "unprivileged" UDP ping. true means pinger will send a "privileged" raw ICMP ping. NOTE: setting to true requires that it be run with super-user privileges.

func (*Pinger) SetTrafficClass added in v0.5.0

func (p *Pinger) SetTrafficClass(tc uint8)

SetTrafficClass sets the traffic class (type-of-service field for IPv4) field value for future outgoing packets.

func (*Pinger) Statistics

func (p *Pinger) Statistics() *Statistics

Statistics returns the statistics of the pinger. This can be run while the pinger is running or after it is finished. OnFinish calls this function to get it's finished statistics.

func (*Pinger) Stop

func (p *Pinger) Stop()

func (*Pinger) TrafficClass added in v0.5.0

func (p *Pinger) TrafficClass() uint8

TrafficClass returns the traffic class field (type-of-service field for IPv4) value for outgoing packets.

type Statistics

type Statistics struct {
	// PacketsRecv is the number of packets received.
	PacketsRecv int

	// PacketsSent is the number of packets sent.
	PacketsSent int

	// PacketsRecvDuplicates is the number of duplicate responses there were to a sent packet.
	PacketsRecvDuplicates int

	// PacketLoss is the percentage of packets lost.
	PacketLoss float64

	// IPAddr is the address of the host being pinged.
	IPAddr *net.IPAddr

	// Addr is the string address of the host being pinged.
	Addr string

	// Rtts is all of the round-trip times sent via this pinger.
	Rtts []time.Duration

	// TTLs is all of the TTLs received via this pinger.
	TTLs []uint8

	// MinRtt is the minimum round-trip time sent via this pinger.
	MinRtt time.Duration

	// MaxRtt is the maximum round-trip time sent via this pinger.
	MaxRtt time.Duration

	// AvgRtt is the average round-trip time sent via this pinger.
	AvgRtt time.Duration

	// StdDevRtt is the standard deviation of the round-trip times sent via
	// this pinger.
	StdDevRtt time.Duration
}

Statistics represent the stats of a currently running or finished pinger operation.

type StdLogger

type StdLogger struct {
	Logger *log.Logger
}

func (StdLogger) Debugf

func (l StdLogger) Debugf(format string, v ...interface{})

func (StdLogger) Errorf

func (l StdLogger) Errorf(format string, v ...interface{})

func (StdLogger) Fatalf

func (l StdLogger) Fatalf(format string, v ...interface{})

func (StdLogger) Infof

func (l StdLogger) Infof(format string, v ...interface{})

func (StdLogger) Warnf

func (l StdLogger) Warnf(format string, v ...interface{})

type TraceSuite added in v0.4.0

type TraceSuite struct {
	Extra any
	// contains filtered or unexported fields
}

TraceSuite is a struct that is passed to each callback. It contains a bunch of time helpers, that you can use with a corresponding getter. These timers are set before making a corresponding callback, meaning that when an onDNSStart callback will be called - TraceSuite will already have filled dnsStart field. In addition to that, it contains an Extra field of type any which you can use in any custom way you might need. Before each callback call, mutex is used, meaning all operations inside your callback are concurrent-safe. Keep in mind, that if your http client set up to follow redirects - timers will be overwritten.

func (*TraceSuite) GetConnEnd added in v0.4.0

func (s *TraceSuite) GetConnEnd() time.Time

GetConnEnd returns a time of a connection dial end.

func (*TraceSuite) GetConnStart added in v0.4.0

func (s *TraceSuite) GetConnStart() time.Time

GetConnStart returns a time of a connection dial start.

func (*TraceSuite) GetDNSEnd added in v0.4.0

func (s *TraceSuite) GetDNSEnd() time.Time

GetDNSEnd returns a time of a dns lookup send.

func (*TraceSuite) GetDNSStart added in v0.4.0

func (s *TraceSuite) GetDNSStart() time.Time

GetDNSStart returns a time of a dns lookup start.

func (*TraceSuite) GetFirstByteReceived added in v0.4.0

func (s *TraceSuite) GetFirstByteReceived() time.Time

GetFirstByteReceived returns a time when first response bytes were received.

func (*TraceSuite) GetGeneralEnd added in v0.4.0

func (s *TraceSuite) GetGeneralEnd() time.Time

GetGeneralEnd returns a general http response time.

func (*TraceSuite) GetGeneralStart added in v0.4.0

func (s *TraceSuite) GetGeneralStart() time.Time

GetGeneralStart returns a general http request execution start time.

func (*TraceSuite) GetTLSEnd added in v0.4.0

func (s *TraceSuite) GetTLSEnd() time.Time

GetTLSEnd returns a time of a tls handshake end.

func (*TraceSuite) GetTLSStart added in v0.4.0

func (s *TraceSuite) GetTLSStart() time.Time

GetTLSStart returns a time of a tls handshake start.

func (*TraceSuite) GetWroteHeaders added in v0.4.0

func (s *TraceSuite) GetWroteHeaders() time.Time

GetWroteHeaders returns a time when request headers were written.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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