stats

package
v0.0.0-...-9a529fd Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2017 License: MIT Imports: 5 Imported by: 6

Documentation

Overview

Package stats supports the collection of metrics from a running component.

Index

Constants

This section is empty.

Variables

View Source
var DefaultTTL uint = 0

DefaultTTL for the registry

View Source
var Enabled = true

Enabled activates stats collection

View Source
var Registry = NewRegistry()

Registry is the default metrics registry

Functions

func DecCounter

func DecCounter(name string)

DecCounter decrements a counter by 1

func IncCounter

func IncCounter(name string)

IncCounter increments a counter by 1

func Initialize

func Initialize()

Initialize the stats

func MarkMeter

func MarkMeter(name string)

MarkMeter registers an event

func NewRegistry

func NewRegistry() metrics.Registry

NewRegistry reates a new registry and starts a goroutine for the TTL.

func SetString

func SetString(name, tag, value string)

SetString ...

func SetTimeout

func SetTimeout(name string, ttl uint)

SetTimeout ...

func UpdateHistogram

func UpdateHistogram(name string, value int64)

UpdateHistogram registers a new value for a histogram

Types

type NilString

type NilString struct{}

NilString is a no-op String.

func (NilString) Get

func (NilString) Get() map[string]string

Get is a no-op.

func (NilString) Set

func (NilString) Set(t, s string)

Set is a no-op.

func (NilString) Snapshot

func (NilString) Snapshot() String

Snapshot is a no-op.

type StandardString

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

StandardString is the standard implementation of a String.

func (*StandardString) Get

func (m *StandardString) Get() map[string]string

Get returns the number of events recorded.

func (*StandardString) Set

func (m *StandardString) Set(tag, str string)

Set sets the String to the given value.

func (*StandardString) Snapshot

func (m *StandardString) Snapshot() String

Snapshot returns a read-only copy of the string.

type String

type String interface {
	Get() map[string]string
	Set(string, string)
	Snapshot() String
}

String stores a string

func GetOrRegisterString

func GetOrRegisterString(name string, r metrics.Registry) String

GetOrRegisterString returns an existing String or constructs and registers a new StandardString.

func NewRegisteredString

func NewRegisteredString(name string, r metrics.Registry) String

NewRegisteredString constructs and registers a new StandardString.

func NewString

func NewString() String

NewString constructs a new StandardString.

type StringSnapshot

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

StringSnapshot is a read-only copy of another String.

func (*StringSnapshot) Get

func (m *StringSnapshot) Get() map[string]string

Get returns the value of events at the time the snapshot was taken.

func (*StringSnapshot) Set

func (*StringSnapshot) Set(t, v string)

Set panics.

func (*StringSnapshot) Snapshot

func (m *StringSnapshot) Snapshot() String

Snapshot returns the snapshot.

type TTNRegistry

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

TTNRegistry is a mutex-protected map of names to metrics. It is basically an extension of https://github.com/rcrowley/go-metrics/blob/master/registry.go

func (*TTNRegistry) Each

func (r *TTNRegistry) Each(f func(string, interface{}))

Each calls the given function for each registered metric.

func (*TTNRegistry) Get

func (r *TTNRegistry) Get(name string) interface{}

Get the metric by the given name or nil if none is registered.

func (*TTNRegistry) GetOrRegister

func (r *TTNRegistry) GetOrRegister(name string, i interface{}) interface{}

GetOrRegister gets an existing metric or creates and registers a new one. Threadsafe alternative to calling Get and Register on failure. The interface can be the metric to register if not found in registry, or a function returning the metric for lazy instantiation.

func (*TTNRegistry) Register

func (r *TTNRegistry) Register(name string, i interface{}) error

Register the given metric under the given name. Returns a DuplicateMetric if a metric by the given name is already registered.

func (*TTNRegistry) Renew

func (r *TTNRegistry) Renew(name string)

Renew sets the TTL of a metric to the default value

func (*TTNRegistry) RunHealthchecks

func (r *TTNRegistry) RunHealthchecks()

RunHealthchecks runs all registered healthchecks.

func (*TTNRegistry) SetDefaultTTL

func (r *TTNRegistry) SetDefaultTTL(ticks uint)

SetDefaultTTL sets a default TTL of a number of ticks for all new metrics

func (*TTNRegistry) SetTTL

func (r *TTNRegistry) SetTTL(name string, ticks uint)

SetTTL sets a TTL of a number of ticks for a given metric

func (*TTNRegistry) Tick

func (r *TTNRegistry) Tick()

Tick decreases the TTL of all metrics that have one If the TTL becomes zero, the metric is deleted

func (*TTNRegistry) Unregister

func (r *TTNRegistry) Unregister(name string)

Unregister the metric with the given name.

func (*TTNRegistry) UnregisterAll

func (r *TTNRegistry) UnregisterAll()

UnregisterAll unregisters all metrics. (Mostly for testing.)

type Ticker

type Ticker interface {
	Tick()
	SetDefaultTTL(uint)
	SetTTL(string, uint)
	Renew(string)
}

Ticker has a Tick() func

Jump to

Keyboard shortcuts

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