metrics

package
v0.0.0-...-83e654d Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package metrics implements simple general counter-metrics. Metrics are enabled by default. If you want to disable metrics, build with: go build -tags disablemetrics

Index

Constants

View Source
const (
	DefaultAverageLatencyJSONValue = "\"\""
	MilliPerNano                   = 1000000
)

Variables

This section is empty.

Functions

func AddToMaps

func AddToMaps(key string, value int64, maps ...Map)

func HttpHandler

func HttpHandler(rw http.ResponseWriter, r *http.Request)

HttpHandler is a HTTP handler writing the current metrics to the http.ResponseWriter

func LogOnDebugLevel

func LogOnDebugLevel()

LogOnDebugLevel logs all the current metrics, if logging is on Debug level.

func RegisterInterval

func RegisterInterval(ctx context.Context, m Map, td time.Duration, reset func(Map, time.Time), processAndReset func(Map, time.Duration, time.Time))

func SetAverage

func SetAverage(m Map, key string, totalVar, casesVar expvar.Var, scale int64, defaultValue string)

func SetRate

func SetRate(m Map, key string, value expvar.Var, timeframe, unit time.Duration)

Types

type Int

type Int interface {
	Add(int64)
	Set(int64)
}

Int is an interface for some of the operations defined on expvar.Int

func NewInt

func NewInt(name string) Int

NewInt returns an expvar Int, depending on the absence of build tag declared at the beginning of this file

type Map

type Map interface {
	Init() *expvar.Map
	Get(key string) expvar.Var
	Set(key string, av expvar.Var)
	Add(key string, delta int64)
}

Map is an interface for some of the operations defined on expvar.Map

func NewMap

func NewMap(name string) Map

type NS

type NS string

NS is a namespace

func (NS) NewInt

func (ns NS) NewInt(key string) Int

func (NS) NewMap

func (ns NS) NewMap(key string) Map

func (NS) NewNS

func (ns NS) NewNS(childKey string) NS

type Time

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

func NewTime

func NewTime(timeValue time.Time) Time

func (Time) String

func (t Time) String() string

Jump to

Keyboard shortcuts

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