stats

package
v0.0.0-...-0f4f8fd Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsStatField

func AsStatField(input string) string

Convert a string to a stat name by replacing '.' with '_', lowercasing the string and trimming it. Doesn't do any validation, so do try this out locally before sending stats.

func HTTPReturnJson

func HTTPReturnJson(w http.ResponseWriter, result interface{})

func NewStatsd

func NewStatsd(config *StatsdConfig) (*theStatsdReporter, error)

The config.Prefix is sent before each message and can be used to set API keys. The prefix is used as the key prefix. If config is nil, creates a noop reporter.

st, e := NewStatsd(config, "ironmq")
st.Inc("enqueue", 1) -> Actually records to key ironmq.enqueue.

func StartReportingMemoryAndGC

func StartReportingMemoryAndGC(reporter Statter, d time.Duration)

Types

type Aggregator

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

Aggregator collects a stats and merges them together if they've been added previously. Useful for reporters that have low throughput ie stathat.

func (*Aggregator) Gauge

func (r *Aggregator) Gauge(component string, stat string, value int64, rate float32)

func (*Aggregator) Inc

func (r *Aggregator) Inc(component string, stat string, value int64, rate float32)

func (*Aggregator) Measure

func (r *Aggregator) Measure(component string, stat string, value int64, rate float32)

func (*Aggregator) NewTimer

func (r *Aggregator) NewTimer(component string, stat string, rate float32) *Timer

func (*Aggregator) Time

func (r *Aggregator) Time(component string, stat string, value time.Duration, rate float32)

type Config

type Config struct {
	Interval float64 `json:"interval" envconfig:"STATS_INTERVAL"` // seconds
	History  int     // minutes

	Log      string `json:"log" envconfig:"STATS_LOG"`
	StatHat  *StatHatReporterConfig
	NewRelic *NewRelicReporterConfig
	Statsd   *StatsdConfig
	GCStats  int `json:"gc_stats" envconfig:"GC_STATS"` // seconds
}

type HTTPSubHandler

type HTTPSubHandler interface {
	HTTPHandler(relativeUrl []string, w http.ResponseWriter, r *http.Request)
}

type LogReporter

type LogReporter struct {
}

func NewLogReporter

func NewLogReporter() *LogReporter

type MultiStatter

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

func (*MultiStatter) Gauge

func (s *MultiStatter) Gauge(component string, stat string, value int64, rate float32)

func (*MultiStatter) Inc

func (s *MultiStatter) Inc(component string, stat string, value int64, rate float32)

func (*MultiStatter) Measure

func (s *MultiStatter) Measure(component string, stat string, value int64, rate float32)

func (*MultiStatter) NewTimer

func (s *MultiStatter) NewTimer(component string, stat string, rate float32) *Timer

func (*MultiStatter) Time

func (s *MultiStatter) Time(component string, stat string, value time.Duration, rate float32)

type NewRelicAgentConfig

type NewRelicAgentConfig struct {
	Host    string `json:"host"`
	Version string `json:"version"`
	Pid     int    `json:"pid"`
}

type NewRelicReporter

type NewRelicReporter struct {
	Agent      *agent
	LicenseKey string
}

func NewNewRelicReporter

func NewNewRelicReporter(version string, licenseKey string) *NewRelicReporter

type NewRelicReporterConfig

type NewRelicReporterConfig struct {
	Agent      *NewRelicAgentConfig
	LicenseKey string `json:"license_key"`
}

type NilStatter

type NilStatter struct{}

func (*NilStatter) Gauge

func (n *NilStatter) Gauge(component string, stat string, value int64, rate float32)

func (*NilStatter) Inc

func (n *NilStatter) Inc(component string, stat string, value int64, rate float32)

func (*NilStatter) Measure

func (n *NilStatter) Measure(component string, stat string, value int64, rate float32)

func (*NilStatter) NewTimer

func (r *NilStatter) NewTimer(component string, stat string, rate float32) *Timer

func (*NilStatter) Time

func (n *NilStatter) Time(component string, stat string, value time.Duration, rate float32)

type StatHatReporterConfig

type StatHatReporterConfig struct {
	Email  string
	Prefix string
}

type StatsdConfig

type StatsdConfig struct {
	StatsdUdpTarget string `json:"target" mapstructure:"target" envconfig:"STATSD_TARGET"`
	Interval        int64  `json:"interval" envconfig:"STATSD_INTERVAL"`
	Prefix          string `json:"prefix" envconfig:"STATSD_PREFIX"`
}

type Statter

type Statter interface {
	Inc(component string, stat string, value int64, rate float32)
	Gauge(component string, stat string, value int64, rate float32)
	Measure(component string, stat string, value int64, rate float32)
	Time(component string, stat string, value time.Duration, rate float32)
	NewTimer(component string, stat string, rate float32) *Timer
}

func New

func New(config Config) Statter

type Timer

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

statsd like API on top of the map manipulation API.

func (*Timer) Measure

func (timer *Timer) Measure()

Jump to

Keyboard shortcuts

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