Documentation ¶
Index ¶
- type BasePrinter
- type Config
- type Counter
- type Gauge
- type Metrics
- func (m *Metrics) Counter(name string) *Counter
- 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) IntervalSnapshot() map[string]int64
- 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) Run() error
- func (m *Metrics) Shutdown()
- type Printer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasePrinter ¶
type BasePrinter struct { }
BasePrinter simply logs stats as structured log
func NewBasePrinter ¶
func NewBasePrinter() *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 (*BasePrinter) Print(snapshot map[string]int64)
Print logs stats data using global logger with info level
type Config ¶ added in v1.0.1
type Config struct { Log bool LogInterval int LogFormatter string HTTP string Host string Port int }
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 Log is true
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 Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics stores some useful stats about node
func FromConfig ¶ added in v1.0.1
FromConfig creates a new metrics instance from the prodived configuration
func NewMetrics ¶
NewMetrics build new metrics struct
func (*Metrics) EachCounter ¶
EachCounter applies function f(*Gauge) to each gauge in a set
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