metrics

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

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 is a wrapper around a set of int64s that count things. It encapsulates both absolute monotonic counter (incremented atomically), and periodic delta which is updated every `app.config.NodeMetricsInterval`.

func NewCounter

func NewCounter() *Counter

NewCounter creates new Counter.

func (*Counter) Add

func (c *Counter) Add(n int64) int64

Add adds the given number to the counter and returns the new value.

func (*Counter) Inc

func (c *Counter) Inc() int64

Inc is equivalent to Add(name, 1)

func (*Counter) IntervalValue

func (c *Counter) IntervalValue() int64

IntervalValue allows to get last interval value for counter.

func (*Counter) UpdateDelta

func (c *Counter) UpdateDelta()

UpdateDelta updates the delta value for last interval based on current value and previous value.

func (*Counter) Value

func (c *Counter) Value() int64

Value allows to get raw counter value.

type CounterRegistry

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

CounterRegistry contains counters with specified names.

func NewCounterRegistry

func NewCounterRegistry() *CounterRegistry

NewCounterRegistry creates new CounterRegistry.

func (*CounterRegistry) Add

func (r *CounterRegistry) Add(name string, n int64) int64

Add by name. Should only be called after registry already initialized.

func (*CounterRegistry) Get

func (r *CounterRegistry) Get(name string) *Counter

Get allows to get Counter from registry.

func (*CounterRegistry) Inc

func (r *CounterRegistry) Inc(name string) int64

Inc by name. Should only be called after registry already initialized.

func (*CounterRegistry) LoadIntervalValues

func (r *CounterRegistry) LoadIntervalValues(names ...string) map[string]int64

LoadIntervalValues allows to get union of last interval snapshot values over registered counters. Should only be called after registry already initialized.

func (*CounterRegistry) LoadValues

func (r *CounterRegistry) LoadValues(names ...string) map[string]int64

LoadValues allows to get union of raw counter values over registered counters. Should only be called after registry already initialized.

func (*CounterRegistry) Register

func (r *CounterRegistry) Register(name string, c *Counter)

Register allows to register Counter in registry.

func (*CounterRegistry) UpdateDelta

func (r *CounterRegistry) UpdateDelta()

UpdateDelta updates snapshot counter values. Should only be called after registry already initialized.

type Gauge

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

Gauge represents a current value of sth.

func NewGauge

func NewGauge() *Gauge

NewGauge initializes Gauge.

func (*Gauge) Load

func (g *Gauge) Load() int64

Load allows to get gauge value.

func (*Gauge) Set

func (g *Gauge) Set(value int64)

Set allows to set gauge value.

type GaugeRegistry

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

GaugeRegistry is a registry of gauges by name.

func NewGaugeRegistry

func NewGaugeRegistry() *GaugeRegistry

NewGaugeRegistry creates new GaugeRegistry.

func (*GaugeRegistry) Get

func (r *GaugeRegistry) Get(name string) *Gauge

Get allows to get Gauge from registry by name.

func (*GaugeRegistry) LoadValues

func (r *GaugeRegistry) LoadValues(names ...string) map[string]int64

LoadValues allows to get union of gauge values over registered gauges.

func (*GaugeRegistry) Register

func (r *GaugeRegistry) Register(name string, c *Gauge)

Register allows to register Gauge in registry.

func (*GaugeRegistry) Set

func (r *GaugeRegistry) Set(name string, value int64)

Set allows to set gauge value in registry by name.

type HDRHistogram

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

HDRHistogram is a synchronized wrapper over github.com/codahale/hdrhistogram.WindowedHistogram

func NewHDRHistogram

func NewHDRHistogram(nHistograms int, minValue, maxValue int64, sigfigs int, quantiles []float64, quantity string) *HDRHistogram

NewHDRHistogram creates new HDRHistogram.

func (*HDRHistogram) LoadValues

func (h *HDRHistogram) LoadValues() map[string]int64

LoadValues allows to export map of histogram values - both current and merged.

func (*HDRHistogram) MergedSnapshot

func (h *HDRHistogram) MergedSnapshot() *hdr.Histogram

MergedSnapshot allows to get snapshot of merged histogram in a thread-safe way.

func (*HDRHistogram) RecordMicroseconds

func (h *HDRHistogram) RecordMicroseconds(value time.Duration) error

RecordMicroseconds allows to record time.Duration value as microseconds.

func (*HDRHistogram) RecordValue

func (h *HDRHistogram) RecordValue(value int64) error

RecordValue is wrapper over github.com/codahale/hdrhistogram.WindowedHistogram.RecordValue with extra mutex protection to allow concurrent writes.

func (*HDRHistogram) Rotate

func (h *HDRHistogram) Rotate()

Rotate histogram.

func (*HDRHistogram) Snapshot

func (h *HDRHistogram) Snapshot() *hdr.Histogram

Snapshot allows to get snapshot of current histogram in a thread-safe way.

type HDRHistogramRegistry

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

HDRHistogramRegistry is a wrapper to deal with several HDRHistogram instances. After it has been initialized you only can write values into histograms and extract data - do not register histograms dinamically after initial setup.

func NewHDRHistogramRegistry

func NewHDRHistogramRegistry() *HDRHistogramRegistry

NewHDRHistogramRegistry creates new HDRHistogramRegistry.

func (*HDRHistogramRegistry) Get

Get allows to get Gauge from registry.

func (*HDRHistogramRegistry) LoadValues

func (r *HDRHistogramRegistry) LoadValues(names ...string) map[string]int64

LoadValues allows to get union of metric values over registered histograms - both for current and merged over all buckets. If names not provided then return values for all registered histograms.

func (*HDRHistogramRegistry) RecordMicroseconds

func (r *HDRHistogramRegistry) RecordMicroseconds(name string, value time.Duration) error

RecordMicroseconds into histogram with provided name. Noop if name not registered.

func (*HDRHistogramRegistry) RecordValue

func (r *HDRHistogramRegistry) RecordValue(name string, value int64) error

RecordValue into histogram with provided name. Noop if name not registered.

func (*HDRHistogramRegistry) Register

func (r *HDRHistogramRegistry) Register(name string, h *HDRHistogram)

Register allows to register HDRHistogram in registry so you can use its name later to record values over registry instance using RecordValue and RecordMicroseconds methods.

func (*HDRHistogramRegistry) Rotate

func (r *HDRHistogramRegistry) Rotate()

Rotate all registered histograms.

type Registry

type Registry struct {
	Gauges        *GaugeRegistry
	Counters      *CounterRegistry
	HDRHistograms *HDRHistogramRegistry
}

Registry contains various Centrifugo statistic and metric information aggregated once in a configurable interval.

var DefaultRegistry *Registry

func NewRegistry

func NewRegistry() *Registry

NewRegistry initializes Registry.

func (*Registry) RegisterCounter

func (m *Registry) RegisterCounter(name string, c *Counter)

RegisterCounter allows to register counter in registry.

func (*Registry) RegisterGauge

func (m *Registry) RegisterGauge(name string, g *Gauge)

RegisterGauge allows to register gauge in registry.

func (*Registry) RegisterHDRHistogram

func (m *Registry) RegisterHDRHistogram(name string, h *HDRHistogram)

RegisterHDRHistogram allows to register hdr histogram in registry.

Jump to

Keyboard shortcuts

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