trace

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WatchStart = watchType(iota)
	WatchDone
	WatchAll
)

Variables

This section is empty.

Functions

func Recycle added in v0.1.1

func Recycle(tc *TraceContext)

Types

type TimeSpan

type TimeSpan struct {
	Start time.Time
	Done  time.Time
}

func NewTimeSpan

func NewTimeSpan(start time.Time) TimeSpan

func (TimeSpan) Duration

func (t TimeSpan) Duration() time.Duration

func (TimeSpan) Milliseconds

func (t TimeSpan) Milliseconds() int64

type TraceContext

type TraceContext struct {
	DNS     TimeSpan
	DNSName string // DNSName is populated after "dns_start" event
	DNSErr  error  // DNSErr is populated after "dns_done" event

	TLSHandshake TimeSpan
	TLSConnState *tls.ConnectionState // TLSConnState is populated after "tls_handshake_done" event
	TLSErr       error                // TLSErr is populated after "tls_handshake_done" event

	Connect        TimeSpan
	ConnectAddress string
	ConnectErr     error

	Total     time.Duration // from start to PutIdleConn
	FirstByte time.Duration // from start to GotFirstResponseByte

	OnEvent func(ctx *TraceContext, event string)
	// contains filtered or unexported fields
}

func WithTraceContext

func WithTraceContext(
	ctx context.Context, hook func(ctx *TraceContext, event string), watch watchType,
) (context.Context, *TraceContext)

WithTraceContext should be called before sending the request on the request context the returning context should be set on the request. keep hold of the returning TraceContext and call Recycle on it after all tracing job is done (e.g. finished sending the metrics)

func (*TraceContext) Init

func (tc *TraceContext) Init()

func (*TraceContext) Reset

func (tc *TraceContext) Reset()

func (*TraceContext) Stop

func (tc *TraceContext) Stop()

Jump to

Keyboard shortcuts

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