stat

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Not deprecated since still used in other metrics
	NoSuchKey = "noKey"

	// Deprecated due to complications
	HasValue = "hasValue"
	CacheHit = "cacheHit"

	CacheCollision = "collision"
	CacheExpired   = "expired"
	LocalHasValue  = "localHasValue"
	LocalNoSuchKey = "localNoKey"

	L1NoSuchKey = "L1NoKey"
	L1HasValue  = "L1HasValue"
	L2NoSuchKey = "L2NoKey"
	L1Copy      = "L1Copy"

	// Aerospike Errors - still complicated
	Timeout = "timeout"
	Down    = "down"
)
View Source
const (
	ErrorKey = "error"
	// Context errors
	Canceled         = "canceled"
	DeadlineExceeded = "deadlineExceeded"
)
View Source
const (
	// Pending is the column for the in-flight gauge maintained by the
	// metric.EnterThenExit Inc/Dec pattern. The exporter publishes:
	//   - <op>_pending     -- the current-in-flight counter (defective; see below)
	//   - <op>_pending_Max -- per-bucket peak from the Occupancy CustomCounter
	//
	// Known defects in the underlying mechanism:
	//
	//   1. Bucket-mismatch on Exit. EnterThenExit captures the recent-bucket
	//      index at Enter time and decrements that same bucket on Exit. If
	//      the bucket has rotated between Enter and Exit, the wrong bucket
	//      is decremented -- the previous bucket's value goes negative
	//      while the current bucket's value drifts high.
	//
	//   2. Mutex serialization on Inc/Dec. The Dir typed value is not a
	//      string, so MultiCounter.incrementValueBy takes c.locker.Lock()
	//      on every Enter and Exit. Under high QPS this is a real
	//      serialization point.
	//
	// Defect #1 inflates both _pending (current) and _pending_Max (per-bucket
	// peak); the inflation is in the conservative direction (over-estimation),
	// so the metrics are still operationally useful in different regimes:
	//
	//   - _pending_Max grouped per reporting dimension (e.g. by
	//     availability_zone, environment, op): for high-QPS operations
	//     the per-group peak rises substantially above baseline noise
	//     during fleet-wide saturation events, making this the cleaner
	//     saturation signal for those operations.
	//
	//   - _pending summed across reporting instances: exhibits dramatic
	//     spikes during saturation for any QPS profile, partially
	//     amplified by defect #1. For low-QPS operations where the
	//     per-group _pending_Max signal is lost in baseline noise, the
	//     fleet sum is the more visible saturation signal.
	//
	// _pending_Max is the cleaner peak-concurrency signal for capacity
	// sizing; pick per-operation based on QPS profile.
	Pending = "pending"
	// Shed marks a request that the client did NOT send because the host's
	// circuit breaker was already in the down state when getHost() was
	// called. Distinct from Down, which marks the trip event itself
	// (the request that observed the connection error and called
	// FlagDown). Shed is the count of subsequent requests that the
	// breaker rejected before recovery.
	Shed = "shed"
)
View Source
const (
	Enter = Dir(true)
	Exit  = Dir(false)
)
View Source
const (
	L1Write = "L1Write"
	L2Write = "L2Write"
)
View Source
const (
	EarlyCtxError = "ctx"
)

Variables

This section is empty.

Functions

func ErrorOnly added in v0.10.0

func ErrorOnly() counter.Provider

func ErrorWrap added in v0.13.0

func ErrorWrap(err error) errorWrap

func NewCache

func NewCache() counter.Provider

func NewClient added in v0.13.0

func NewClient() counter.Provider

func NewCtxErrOnly added in v0.13.0

func NewCtxErrOnly() counter.Provider

func NewHttp added in v0.13.0

func NewHttp() counter.Provider

func NewWrite added in v0.10.0

func NewWrite() counter.Provider

func TestMapping added in v0.9.0

func TestMapping(t *testing.T, builder func() counter.Provider)

TestMapping checks to ensure that a standard 1-to-1 mapping between keys and values exists.

Types

type Count added in v0.13.0

type Count uint64

func (Count) Aggregate added in v0.13.0

func (c Count) Aggregate(value interface{})

Implements counter.CustomCounter so that it can be used by counter.CustomCounter

type Dir added in v0.13.0

type Dir bool

Dir (direction) should be true if this is an enter event; otherwise should be false. It is expected that every Dir has an Exit, but that may not always happen.

func (Dir) Aggregate added in v0.13.0

func (_ Dir) Aggregate(value interface{})

Implements counter.CustomCounter so that it can be passed to Occupancy, representing the element side of reduce.

type E added in v0.13.0

type E struct {
	Error string
	Count uint64
}

type GMeter added in v0.13.1

type GMeter struct {
	*gmetric.Service

	Unit           time.Duration
	RecentDuration time.Duration
	NumRecent      int
}

func DefaultGMeter added in v0.13.1

func DefaultGMeter(m *gmetric.Service) *GMeter

func (*GMeter) MOp added in v0.13.1

func (g *GMeter) MOp(location, name, desc string, p counter.Provider) *gmetric.Operation

func (*GMeter) Op added in v0.13.1

func (g *GMeter) Op(location, name, desc string) *gmetric.Operation

type Occupancy added in v0.13.0

type Occupancy struct {
	// Members are exposed due to how gmetrics operates.
	Max uint64 `json:",omitempty"`
	// contains filtered or unexported fields
}

Occupancy keeps track of in-out metrics (not input-output); in-out counters are numbers that track the number of start and end events; with a focus on tracking the maximum number of starts without an end event.

func (*Occupancy) Aggregate added in v0.13.0

func (a *Occupancy) Aggregate(value interface{})

Aggregate implements counter.CustomCounter, but represents the aggregate side.

type Sum added in v0.13.0

type Sum struct {
	Total uint64 `json:",omitempty"`
}

TODO consider https://github.com/beorn7/perks

func (*Sum) Aggregate added in v0.13.0

func (s *Sum) Aggregate(value interface{})

type TopK added in v0.13.0

type TopK struct {
	Top []E
	// contains filtered or unexported fields
}

func NewTopK added in v0.13.0

func NewTopK(n, mod int) *TopK

func (*TopK) Aggregate added in v0.13.0

func (k *TopK) Aggregate(value interface{})

implements github.com/viant/gmetric/counter.CustomCounter

type Values

type Values []interface{}

Values is a utility to pass multiple events to gmetric.

func NewValues

func NewValues() *Values

func (*Values) Append

func (v *Values) Append(item interface{})

func (*Values) AppendError added in v0.9.0

func (v *Values) AppendError(err error)

func (*Values) Values

func (v *Values) Values() []interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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