Documentation
¶
Overview ¶
Package telemetry defines a minimal, dependency-free observability hook that every HTTP request in this module reports through. Consumers wire their own metrics/logging backend by implementing Hook; the zero value (NoopHook) does nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
type Func func(RequestEvent)
Func adapts a plain function to the Hook interface.
func (Func) OnRequest ¶
func (f Func) OnRequest(e RequestEvent)
type Hook ¶
type Hook interface {
OnRequest(RequestEvent)
}
Hook receives a callback for every request attempt. Implementations must be safe for concurrent use, since requests may be issued concurrently by callers.
type NoopHook ¶
type NoopHook struct{}
NoopHook implements Hook by doing nothing. It is the default when no hook is configured.
func (NoopHook) OnRequest ¶
func (NoopHook) OnRequest(RequestEvent)
type RequestEvent ¶
type RequestEvent struct {
API API
Operation string
Method string
URL string
Status int // zero if the request never got an HTTP response
Err error // non-nil on transport-level failure
Duration time.Duration
Attempt int // 0 for the first attempt, incremented per retry
}
RequestEvent describes one completed (or failed) HTTP request.
Click to show internal directories.
Click to hide internal directories.