Documentation ¶
Index ¶
- func AddFlags()
- func AddToValue(key string, value float64)
- func AreLogged() bool
- func Clear()
- func GetCounter(key string) int64
- func GetValue(key string) float64
- func IncrementCounter(key string)
- func IncrementCounterBy(key string, value int64)
- func TrackTime(key string, start time.Time, unit time.Duration)
- func Write() error
- func WriteAndLogError()
- type Stats
- func (s *Stats) AddFlags()
- func (s *Stats) AddToValue(key string, value float64)
- func (s *Stats) AreLogged() bool
- func (s *Stats) Clear()
- func (s *Stats) GetCounter(key string) int64
- func (s *Stats) GetValue(key string) float64
- func (s *Stats) IncrementCounter(key string)
- func (s *Stats) IncrementCounterBy(key string, value int64)
- func (s *Stats) TrackTime(key string, start time.Time, unit time.Duration)
- func (s *Stats) Write() error
- func (s *Stats) WriteAndLogError()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddToValue ¶
AddToValue adds to the value associated with the global key
func Clear ¶
func Clear()
Clear will empty out the global stats, all counters are set to 0, all values set to 0
func GetCounter ¶
GetCounter returns the global count associated with the key
func IncrementCounter ¶
func IncrementCounter(key string)
IncrementCounter increments the global counter associated with the key by 1
func IncrementCounterBy ¶
IncrementCounterBy increments the global counter associated with the key by the given value
func TrackTime ¶
TrackTime will track how much time was elapsed from start time, and add that value (in given unit) to the global value associated with the key should be used like this
func Something() { defer stats.TrackTime(key, time.Now(), time.Second) .. do some operation }
func Write ¶
func Write() error
Write will write all global stats to stderr and/or a file. configured through stats.OutputFile and stats.sLogToStderr
func WriteAndLogError ¶
func WriteAndLogError()
WriteAndLogError is just a wrapper around Write which also logs the error to stderr if it occurs
Types ¶
type Stats ¶
Stats encapsulates functionallity of incrementing counters and incrementing values
func (*Stats) AddFlags ¶
func (s *Stats) AddFlags()
AddFlags adds configuration flags for a stats object
func (*Stats) AddToValue ¶
AddToValue adds to the value associated with the key
func (*Stats) AreLogged ¶
AreLogged returns whether this stats object is getting logged can be used to determine whether to keep adding stuff to it or not if it's not being logged, one shouldn't even increment counters
func (*Stats) Clear ¶
func (s *Stats) Clear()
Clear will empty out the stats, all counters are set to 0, all values set to 0
func (*Stats) GetCounter ¶
GetCounter returns the count associated with the key
func (*Stats) IncrementCounter ¶
IncrementCounter increments the counter associated with the key by 1
func (*Stats) IncrementCounterBy ¶
IncrementCounterBy increments the counter associated with the key by the given value
func (*Stats) TrackTime ¶
TrackTime will track how much time was elapsed from start time, and add that value (in given unit) to the value associated with the key should be used like this
func Something() { defer stats.TrackTime(key, time.Now(), time.Second) .. do some operation }
func (*Stats) Write ¶
Write will write all stats to stderr and/or a file. configured through stats.OutputFile and stats.sLogToStderr
func (*Stats) WriteAndLogError ¶
func (s *Stats) WriteAndLogError()
WriteAndLogError is just a wrapper around Write which also logs the error to stderr if it occurs