metrics

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package metrics provides metrics view of variables which is exposed through expvar package.

Naming conventions: 1. volatile path components should be kept as deep into the hierarchy as possible 2. each path component should have a clear and well-defined purpose 3. components.separated.with.dot, and put package prefix at the head 4. words_separated_with_underscore, and put clarifiers last, e.g., requests_total

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(f func(expvar.KeyValue))

Do calls f for each exported variable. The global variable map is locked during the iteration, but existing entries may be concurrently updated.

func Get

func Get(name string) expvar.Var

Get retrieves a named exported variable.

func Publish

func Publish(name string, v expvar.Var)

Publish declares a named exported variable. If the name is already registered then this will overwrite the old one.

Types

type Counter

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

Counter is a number that increases over time monotonically.

func NewCounter

func NewCounter(name string) *Counter

Convenience functions for creating new exported variables.

func (*Counter) Add

func (c *Counter) Add()

func (*Counter) AddBy

func (c *Counter) AddBy(delta int64)

func (*Counter) String

func (c *Counter) String() string

type Gauge

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

Gauge returns instantaneous value that is expected to fluctuate over time.

func NewGauge

func NewGauge(name string) *Gauge

func (*Gauge) Set

func (g *Gauge) Set(value int64)

func (*Gauge) String

func (g *Gauge) String() string

type Map

type Map struct{ *expvar.Map }

Map aggregates Counters and Gauges.

func GetMap

func GetMap(name string) *Map

GetMap returns the map if it exists, or inits the given name map if it does not exist.

func NewMap

func NewMap(name string) *Map

func (*Map) Delete

func (m *Map) Delete(key string)

TODO: remove the var from the map to avoid memory boom

func (*Map) NewCounter

func (m *Map) NewCounter(key string) *Counter

func (*Map) NewGauge

func (m *Map) NewGauge(key string) *Gauge

func (*Map) String

func (m *Map) String() string

String returns JSON format string that represents the group. It does not print out nilVar.

Jump to

Keyboard shortcuts

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