stats

package
v0.0.0-...-b89db3d Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReqEvent

type ReqEvent struct {
	// Time is the time the request event happened.
	Time time.Time
	// Type is the type of the request event.
	Type ReqEventType
	// Key is the revision the event is associated with.
	// +optional
	Key types.NamespacedName
}

ReqEvent represents either an incoming or closed request.

type ReqEventType

type ReqEventType int

ReqEventType denotes the type (incoming/closed) of a ReqEvent.

const (
	// ReqIn represents an incoming request
	ReqIn ReqEventType = iota
	// ReqOut represents a finished request
	ReqOut
	// ProxiedIn represents an incoming request through a proxy.
	ProxiedIn
	// ProxiedOut represents a finished proxied request.
	ProxiedOut
)

type RequestStats

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

RequestStats collects statistics about requests as they flow in and out of the system.

func NewRequestStats

func NewRequestStats(startedAt time.Time) *RequestStats

NewRequestStats builds a RequestStats instance, started at the given time.

func (*RequestStats) HandleEvent

func (s *RequestStats) HandleEvent(event ReqEvent)

HandleEvent handles an incoming or outgoing request event and updates the state accordingly.

func (*RequestStats) Report

func (s *RequestStats) Report(now time.Time) RequestStatsReport

Report returns a RequestStatsReport relative to the given time. The state will be reset for another reporting cycle afterwards.

type RequestStatsReport

type RequestStatsReport struct {
	// AverageConcurrency is the average concurrency over the reporting timeframe.
	// This is calculated via the utilization at a given concurrency. For example:
	// 2 requests each taking 500ms over a 1s reporting window generate an average
	// concurrency of 1.
	AverageConcurrency float64
	// AverageProxiedConcurrency is the average concurrency of all proxied requests.
	// The same calculation as above applies.
	AverageProxiedConcurrency float64
	// RequestCount is the number of requests that arrived in the current reporting
	// timeframe.
	RequestCount float64
	// ProxiedRequestCount is the number of proxied requests that arrived in the current
	// reporting timeframe.
	ProxiedRequestCount float64
}

RequestStatsReport are the metrics reported from the the request stats collector at a given time.

Jump to

Keyboard shortcuts

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