Documentation ¶
Index ¶
- Constants
- type BasePrinter
- type Config
- type Counter
- type Gauge
- type Instrumenter
- type IntervalWriter
- type Metrics
- func (m *Metrics) Counter(name string) *Counter
- func (m *Metrics) CounterAdd(name string, val uint64)
- func (m *Metrics) CounterIncrement(name string)
- func (m *Metrics) DefaultTags(tags map[string]string)
- func (m *Metrics) EachCounter(f func(c *Counter))
- func (m *Metrics) EachGauge(f func(g *Gauge))
- func (m *Metrics) Gauge(name string) *Gauge
- func (m *Metrics) GaugeDecrement(name string)
- func (m *Metrics) GaugeIncrement(name string)
- func (m *Metrics) GaugeSet(name string, val uint64)
- func (m *Metrics) IntervalSnapshot() map[string]uint64
- func (m *Metrics) Prometheus() string
- func (m *Metrics) PrometheusHandler(w http.ResponseWriter, r *http.Request)
- func (m *Metrics) RegisterCounter(name string, desc string)
- func (m *Metrics) RegisterGauge(name string, desc string)
- func (m *Metrics) RegisterWriter(w IntervalWriter)
- func (m *Metrics) Run() error
- func (m *Metrics) Shutdown(ctx context.Context) (err error)
- type NoopMetrics
- func (NoopMetrics) CounterAdd(name string, val uint64)
- func (NoopMetrics) CounterIncrement(name string)
- func (NoopMetrics) GaugeDecrement(name string)
- func (NoopMetrics) GaugeIncrement(name string)
- func (NoopMetrics) GaugeSet(name string, val uint64)
- func (NoopMetrics) RegisterCounter(name string, desc string)
- func (NoopMetrics) RegisterGauge(name string, desc string)
- type Printer
- type StatsdConfig
- type StatsdLogger
- type StatsdWriter
Constants ¶
const DefaultRotateInterval = 15
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasePrinter ¶
type BasePrinter struct {
// contains filtered or unexported fields
}
BasePrinter simply logs stats as structured log
func NewBasePrinter ¶
func NewBasePrinter(filterList []string) *BasePrinter
NewBasePrinter returns new base printer struct
func NewCustomPrinter ¶
func NewCustomPrinter(path string) (*BasePrinter, error)
NewCustomPrinter generates log formatter from the provided (as path) Ruby script
func (*BasePrinter) Print ¶
func (p *BasePrinter) Print(snapshot map[string]uint64)
Print logs stats data using global logger with info level
func (*BasePrinter) Run ¶ added in v1.1.0
func (p *BasePrinter) Run(interval int) error
Run prints a message to the log with metrics logging details
func (*BasePrinter) Stop ¶ added in v1.1.0
func (p *BasePrinter) Stop()
func (*BasePrinter) Write ¶ added in v1.1.0
func (p *BasePrinter) Write(m *Metrics) error
Write prints formatted snapshot to the log
type Config ¶ added in v1.0.1
type Config struct { Log bool LogInterval int // Deprecated RotateInterval int LogFormatter string // Print only specified metrics LogFilter []string HTTP string Host string Port int Tags map[string]string Statsd StatsdConfig }
Config contains metrics configuration
func (*Config) HTTPEnabled ¶ added in v1.0.1
HTTPEnabled returns true iff HTTP is not empty
func (*Config) LogEnabled ¶ added in v1.0.1
LogEnabled returns true iff any log option is specified
func (*Config) LogFormatterEnabled ¶ added in v1.0.1
LogFormatterEnabled returns true iff LogFormatter is not empty
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter stores information about something "countable". Store
func NewCounter ¶
NewCounter creates new Counter.
func (*Counter) IntervalValue ¶
IntervalValue allows to get last interval value for counter.
func (*Counter) UpdateDelta ¶
func (c *Counter) UpdateDelta()
UpdateDelta updates the delta value for last interval based on current value and previous value.
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge stores an int value
type Instrumenter ¶ added in v1.2.2
type IntervalWriter ¶ added in v1.1.0
IntervalHandler describe a periodical metrics writer interface
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics stores some useful stats about node
func NewFromConfig ¶ added in v1.2.3
NewFromConfig creates a new metrics instance from the prodived configuration
func NewMetrics ¶
func NewMetrics(writers []IntervalWriter, rotateIntervalSeconds int) *Metrics
NewMetrics build new metrics struct
func (*Metrics) CounterAdd ¶ added in v1.2.2
CounterAdd adds a value to the given counter
func (*Metrics) CounterIncrement ¶ added in v1.2.2
CounterIncrement increments the given counter
func (*Metrics) DefaultTags ¶ added in v1.3.0
func (*Metrics) EachCounter ¶
EachCounter applies function f(*Gauge) to each gauge in a set
func (*Metrics) GaugeDecrement ¶ added in v1.2.2
GaugeDecrement increments the given gauge
func (*Metrics) GaugeIncrement ¶ added in v1.2.2
GaugeIncrement increments the given gauge
func (*Metrics) IntervalSnapshot ¶
IntervalSnapshot returns recorded interval metrics snapshot
func (*Metrics) Prometheus ¶
Prometheus returns metrics info in Prometheus format
func (*Metrics) PrometheusHandler ¶
func (m *Metrics) PrometheusHandler(w http.ResponseWriter, r *http.Request)
PrometheusHandler is provide metrics to the world
func (*Metrics) RegisterCounter ¶
RegisterCounter adds new counter to the registry
func (*Metrics) RegisterGauge ¶
RegisterGauge adds new gauge to the registry
func (*Metrics) RegisterWriter ¶ added in v1.1.0
func (m *Metrics) RegisterWriter(w IntervalWriter)
type NoopMetrics ¶ added in v1.2.2
type NoopMetrics struct { }
func (NoopMetrics) CounterAdd ¶ added in v1.2.2
func (NoopMetrics) CounterAdd(name string, val uint64)
func (NoopMetrics) CounterIncrement ¶ added in v1.2.2
func (NoopMetrics) CounterIncrement(name string)
func (NoopMetrics) GaugeDecrement ¶ added in v1.2.2
func (NoopMetrics) GaugeDecrement(name string)
func (NoopMetrics) GaugeIncrement ¶ added in v1.2.2
func (NoopMetrics) GaugeIncrement(name string)
func (NoopMetrics) GaugeSet ¶ added in v1.2.2
func (NoopMetrics) GaugeSet(name string, val uint64)
func (NoopMetrics) RegisterCounter ¶ added in v1.2.2
func (NoopMetrics) RegisterCounter(name string, desc string)
func (NoopMetrics) RegisterGauge ¶ added in v1.2.2
func (NoopMetrics) RegisterGauge(name string, desc string)
type StatsdConfig ¶ added in v1.3.0
func NewStatsdConfig ¶ added in v1.3.0
func NewStatsdConfig() StatsdConfig
func (StatsdConfig) Enabled ¶ added in v1.3.0
func (c StatsdConfig) Enabled() bool
type StatsdLogger ¶ added in v1.3.0
type StatsdLogger struct {
// contains filtered or unexported fields
}
func (*StatsdLogger) Printf ¶ added in v1.3.0
func (lg *StatsdLogger) Printf(msg string, args ...interface{})
type StatsdWriter ¶ added in v1.3.0
type StatsdWriter struct {
// contains filtered or unexported fields
}
func NewStatsdWriter ¶ added in v1.3.0
func NewStatsdWriter(c StatsdConfig, tags map[string]string) *StatsdWriter
func (*StatsdWriter) Run ¶ added in v1.3.0
func (sw *StatsdWriter) Run(interval int) error
func (*StatsdWriter) Stop ¶ added in v1.3.0
func (sw *StatsdWriter) Stop()
func (*StatsdWriter) Write ¶ added in v1.3.0
func (sw *StatsdWriter) Write(m *Metrics) error