metrics

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	InFlight atomic.Int64
	Requests atomic.Uint64
	Failures atomic.Uint64
	Latency  *Latency
	// contains filtered or unexported fields
}

func NewActivity

func NewActivity() *Activity

NewActivity instantiates operational tracking telemetry Manages concurrency inflight counters and throughput latency

func (*Activity) Close added in v0.1.0

func (at *Activity) Close()

Close shuts down the latency tracker

func (*Activity) EWMA

func (at *Activity) EWMA() int64

EWMA delivers the latest known exponential weight average output Provides lock-free access to traffic speed approximations

func (*Activity) EndRequest

func (at *Activity) EndRequest(duration int64, isFailure bool)

EndRequest decreases active counts and archives the outcome performance Decrements immediately while asynchronously evaluating moving averages

func (*Activity) Snapshot

func (at *Activity) Snapshot() map[string]any

Snapshot freezes ongoing values into a secure map extraction Yields current telemetry structures for reporting components

func (*Activity) StartRequest

func (at *Activity) StartRequest()

StartRequest increases the active connection count Operates automatically and block-free for inbound traffic tracking

type BackendStats

type BackendStats struct {
	Activity *Activity
}

func (*BackendStats) Close

func (s *BackendStats) Close()

type Latency

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

func NewLatency

func NewLatency() *Latency

NewLatency creates a sharded histogram with lazy allocation. Shards start as nil histograms; memory only consumed on actual traffic.

func (*Latency) Close

func (lt *Latency) Close()

Close shuts down the latency tracker and stops background eviction

func (*Latency) Record

func (lt *Latency) Record(microseconds int64)

Record adds a latency sample, allocating histogram on first use per shard. Rotates histograms on time windows; creates histograms lazily.

func (*Latency) Snapshot

func (lt *Latency) Snapshot() LatencySnapshot

Snapshot aggregates all active shards into a unified latency view. Skips unallocated (idle) shards efficiently.

type LatencySnapshot

type LatencySnapshot struct {
	P50   int64  `json:"p50"`
	P90   int64  `json:"p90"`
	P99   int64  `json:"p99"`
	Max   int64  `json:"max"`
	Count uint64 `json:"count"`
	Sum   int64  `json:"sum_us"`
	Avg   int64  `json:"avg_us"`
}

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Clear

func (r *Registry) Clear()

func (*Registry) Close

func (r *Registry) Close()

func (*Registry) Get

func (r *Registry) Get(key alaye.Key) *BackendStats

func (*Registry) GetOrRegister

func (r *Registry) GetOrRegister(key alaye.Key) *BackendStats

func (*Registry) Prune

func (r *Registry) Prune(keepKeys map[alaye.Key]bool)

Jump to

Keyboard shortcuts

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