libprobe

package module
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPStepDNSLookup    = "DNS_LOOKUP"
	HTTPStepConnect      = "CONNECT"
	HTTPStepTLSHandshake = "TLS_HANDSHAKE"
	HTTPStepWriteRequest = "WRITE_REQUEST"
)
View Source
const (
	KindTCP  = "TCP"
	KindHTTP = "HTTP"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClientTrace added in v0.3.5

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

func (*HTTPClientTrace) CreateContext added in v0.3.5

func (t *HTTPClientTrace) CreateContext(ctx context.Context) context.Context

func (*HTTPClientTrace) SetEndTime added in v0.3.6

func (t *HTTPClientTrace) SetEndTime(when time.Time)

func (*HTTPClientTrace) TraceInfo added in v0.3.5

func (t *HTTPClientTrace) TraceInfo() HTTPTraceInfo

type HTTPProber

type HTTPProber struct {
}

func NewHTTPProber

func NewHTTPProber() *HTTPProber

func (*HTTPProber) Kind

func (p *HTTPProber) Kind() string

func (*HTTPProber) Probe

func (p *HTTPProber) Probe(target Target) (Result, error)

type HTTPResult

type HTTPResult struct {
	Target
	Error              error
	DNSResolveTime     time.Duration
	ConnectTime        time.Duration
	TLSHandshakeTime   time.Duration
	TTFB               time.Duration
	TransferTime       time.Duration
	TotalTime          time.Duration
	ResponseStatusCode int
	ResponseSize       int
	ResponseBody       []byte
}

func (HTTPResult) RTT

func (r HTTPResult) RTT() time.Duration

func (HTTPResult) String

func (r HTTPResult) String() string

type HTTPTraceInfo added in v0.3.5

type HTTPTraceInfo struct {
	// FailedStep is the step name that failed while requesting.
	FailedStep string

	// DNSLookup is a duration that transport took to perform
	// DNS lookup.
	DNSLookup time.Duration

	// ConnTime is a duration that took to obtain a successful connection.
	ConnTime time.Duration

	// TCPConnTime is a duration that took to obtain the TCP connection.
	TCPConnTime time.Duration

	// TLSHandshake is a duration that TLS handshake took place.
	TLSHandshake time.Duration

	// RequestSendingTime is a duration that request wrote takes(may contains multiple retries).
	RequestSendingTime time.Duration

	// TTFB(TimeToFirstByte) is a duration that server took to respond first byte.
	TTFB time.Duration

	// ResponseTime is a duration since first response byte from server to
	// request completion.
	ResponseTime time.Duration

	// TotalTime is a duration that total request took end-to-end.
	TotalTime time.Duration

	// IsConnReused is whether this connection has been previously
	// used for another HTTP request.
	IsConnReused bool

	// IsConnWasIdle is whether this connection was obtained from an
	// idle pool.
	IsConnWasIdle bool

	// ConnIdleTime is a duration how long the connection was previously
	// idle, if IsConnWasIdle is true.
	ConnIdleTime time.Duration

	// RemoteAddr returns the remote network address.
	RemoteAddr net.Addr

	// Timestamps
	RequestStartAt      time.Time
	FirstResponseByteAt time.Time
}

type ICMPProber

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

func NewICMPProber

func NewICMPProber(privileged bool) *ICMPProber

func (*ICMPProber) Kind

func (p *ICMPProber) Kind() string

func (*ICMPProber) Probe

func (p *ICMPProber) Probe(target Target) (Result, error)

type ICMPResult

type ICMPResult struct {
	Target

	Stats *ping.Statistics
}

func (ICMPResult) RTT

func (r ICMPResult) RTT() time.Duration

func (ICMPResult) String

func (r ICMPResult) String() string

type Prober

type Prober interface {
	Kind() string
	Probe(target Target) (Result, error)
}

type Result

type Result interface {
	RTT() time.Duration
	String() string
}

type TCPProber

type TCPProber struct {
}

func NewTCPProber

func NewTCPProber() *TCPProber

func (*TCPProber) Kind

func (p *TCPProber) Kind() string

func (*TCPProber) Probe

func (p *TCPProber) Probe(target Target) (Result, error)

type TCPResult

type TCPResult struct {
	Target
	Error       error
	ConnectTime time.Duration
}

func (TCPResult) RTT

func (r TCPResult) RTT() time.Duration

func (TCPResult) String

func (r TCPResult) String() string

type Target

type Target struct {
	// Can be a IP, IP:Port or URL
	Address  string
	Timeout  time.Duration
	Interval time.Duration
	Count    int

	// HTTP Probe only
	RequestMethod string
	Headers       http.Header
	Body          io.Reader
}

func (Target) GetCount

func (t Target) GetCount() int

Jump to

Keyboard shortcuts

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