stat

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

prometheus buried point library.

simple usage:

mgr := New(5 * time.Second)
tick := mgr.NewTick("api_caller")
defet tick.Close()

Tick struct:

this struct is used by api caller, it will automatically calculate
qps, avg_cost, quantile_cost in p0, p50, p90, p99, p100 by samples
by interval of New func.

in prometheus it will export value like below:
<name-by-NewTick>{tag="qps"} <qps-value>
<name-by-NewTick>{tag="avg"} <avg-cost-value>
<name-by-NewTick>{tag="p0"} <0%-cost-value>
...

Counter struct:

this struct is used by single value, it will export value in realtime,
it is supported Set, Inc, Dec, Add, Sub with value.

in prometheus it will export value like below:
<name-by-NewCounter> <value>

RawVec:

you can use RawVec to create the GaugeVec of prometheus,
GaugeVec usage: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#GaugeVec

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

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

Counter single value with counter

func (*Counter) Add

func (ct *Counter) Add(v float64)

Add add value to counter

func (*Counter) Dec

func (ct *Counter) Dec()

Dec decrease counter value

func (*Counter) Inc

func (ct *Counter) Inc()

Inc increase counter value

func (*Counter) Set

func (ct *Counter) Set(v float64)

Set set counter value

func (*Counter) Sub

func (ct *Counter) Sub(v float64)

Sub sub value to counter

type Mgr

type Mgr struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Mgr tick management

func New

func New(interval time.Duration) *Mgr

New create management, the ticks will calculate by every interval time

func (*Mgr) Collect

func (mgr *Mgr) Collect()

Collect compute default values and export

func (*Mgr) NewCounter

func (mgr *Mgr) NewCounter(name string) *Counter

NewCounter create new counter

func (*Mgr) NewTick

func (mgr *Mgr) NewTick(name string) *Tick

NewTick create new tick

func (*Mgr) RawVec

func (mgr *Mgr) RawVec(name string, labels []string) *prometheus.GaugeVec

RawVec get raw GaugeVec by name if not exists, create it

func (*Mgr) ServeHTTP

func (mgr *Mgr) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP responds to an HTTP request

type Tick

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

Tick tick object

func (*Tick) Close

func (tk *Tick) Close()

Jump to

Keyboard shortcuts

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