stats

package
v0.0.0-...-a420e69 Latest Latest
Warning

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

Go to latest
Published: May 24, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Counter

func Counter() gin.HandlerFunc

Counter counts number of requests made to the server

func CreateStatsdClient

func CreateStatsdClient(statsdURL, statsdPrefix string) error

CreateStatsdClient creates a local instances of a statsd client. Any errors will be logged to console and ignored.

func Handler

func Handler(res http.ResponseWriter, req *http.Request)

Handler display a JSON object showing number of requests received Copied from https://golang.org/src/expvar/expvar.go#L305

func ShutdownStatsdClient

func ShutdownStatsdClient()

ShutdownStatsdClient flushes any outstanding stats and terminates connections to statsd.

Types

type Stat

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

Stat holds a named integer counter, which is exported to expvar and statsd

func NewStat

func NewStat(key string) *Stat

NewStat creates a named statistic with the given name

func (*Stat) Add

func (v *Stat) Add(delta int64)

Add increments the integer value stored in this stat

func (*Stat) String

func (v *Stat) String() string

type TimingStat

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

TimingStat holds a timer statistic, internally represented as two counters, total time consumed and number of observations.

func NewTimingStat

func NewTimingStat(key string) *TimingStat

NewTimingStat creates a timing statistic with the given name

func (*TimingStat) Add

func (ts *TimingStat) Add(delta time.Duration)

Add notes a timing event of given duration (increases observation count by one and adds time duration to total time spent in event)

func (*TimingStat) AddTimeSince

func (ts *TimingStat) AddTimeSince(start time.Time)

AddTimeSince calculates time elapsed since given start time and adds it to the stat.

Jump to

Keyboard shortcuts

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