Documentation ¶
Overview ¶
Package metrics provides general system and process level metrics collection.
Index ¶
- Constants
- Variables
- func CollectProcessMetrics(refresh time.Duration)
- func NewCounter(name string) metrics.Counter
- func NewMeter(name string) metrics.Meter
- func NewRegisteredCounter(name string, r metrics.Registry) metrics.Counter
- func NewRegisteredMeter(name string, r metrics.Registry) metrics.Meter
- func NewTimer(name string) metrics.Timer
- func ReadDiskStats(stats *DiskStats) error
- type DiskStats
- type Int64Slice
- type NilResettingTimer
- func (NilResettingTimer) Mean() float64
- func (NilResettingTimer) Percentiles([]float64) []int64
- func (NilResettingTimer) Snapshot() ResettingTimer
- func (NilResettingTimer) Time(func())
- func (NilResettingTimer) Update(time.Duration)
- func (NilResettingTimer) UpdateSince(time.Time)
- func (NilResettingTimer) Values() []int64
- type ResettingTimer
- type ResettingTimerSnapshot
- func (t *ResettingTimerSnapshot) Mean() float64
- func (t *ResettingTimerSnapshot) Percentiles(percentiles []float64) []int64
- func (t *ResettingTimerSnapshot) Snapshot() ResettingTimer
- func (*ResettingTimerSnapshot) Time(func())
- func (*ResettingTimerSnapshot) Update(time.Duration)
- func (*ResettingTimerSnapshot) UpdateSince(time.Time)
- func (t *ResettingTimerSnapshot) Values() []int64
- type StandardResettingTimer
- func (t *StandardResettingTimer) Mean() float64
- func (t *StandardResettingTimer) Percentiles([]float64) []int64
- func (t *StandardResettingTimer) Snapshot() ResettingTimer
- func (t *StandardResettingTimer) Time(f func())
- func (t *StandardResettingTimer) Update(d time.Duration)
- func (t *StandardResettingTimer) UpdateSince(ts time.Time)
- func (t *StandardResettingTimer) Values() []int64
Constants ¶
const InitialResettingTimerSliceCap = 10
Initial slice capacity for the values stored in a ResettingTimer
const MetricsEnabledFlag = "metrics"
MetricsEnabledFlag is the CLI flag name to use to enable metrics collections.
Variables ¶
var Enabled = false
Enabled is the flag specifying if metrics are enable or not.
Functions ¶
func CollectProcessMetrics ¶
CollectProcessMetrics periodically collects various metrics about the running process.
func NewCounter ¶
func NewCounter(name string) metrics.Counter
NewCounter create a new metrics Counter, either a real one of a NOP stub depending on the metrics flag.
func NewMeter ¶
func NewMeter(name string) metrics.Meter
NewMeter create a new metrics Meter, either a real one of a NOP stub depending on the metrics flag.
func NewRegisteredCounter ¶
func NewRegisteredCounter(name string, r metrics.Registry) metrics.Counter
func NewRegisteredMeter ¶
func NewRegisteredMeter(name string, r metrics.Registry) metrics.Meter
func NewTimer ¶
func NewTimer(name string) metrics.Timer
NewTimer create a new metrics Timer, either a real one of a NOP stub depending on the metrics flag.
func ReadDiskStats ¶
ReadDiskStats retrieves the disk IO stats belonging to the current process.
Types ¶
type DiskStats ¶
type DiskStats struct { ReadCount int64 // Number of read operations executed ReadBytes int64 // Total number of bytes read WriteCount int64 // Number of write operations executed WriteBytes int64 // Total number of byte written }
DiskStats is the per process disk io stats.
type Int64Slice ¶
type Int64Slice []int64
Int64Slice attaches the methods of sort.Interface to []int64, sorting in increasing order.
func (Int64Slice) Len ¶
func (s Int64Slice) Len() int
func (Int64Slice) Less ¶
func (s Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (s Int64Slice) Swap(i, j int)
type NilResettingTimer ¶
type NilResettingTimer struct { }
NilResettingTimer is a no-op ResettingTimer.
func (NilResettingTimer) Percentiles ¶
func (NilResettingTimer) Percentiles([]float64) []int64
Percentiles panics.
func (NilResettingTimer) Snapshot ¶
func (NilResettingTimer) Snapshot() ResettingTimer
Snapshot is a no-op.
func (NilResettingTimer) UpdateSince ¶
func (NilResettingTimer) UpdateSince(time.Time)
UpdateSince is a no-op.
type ResettingTimer ¶
type ResettingTimer interface { Values() []int64 Snapshot() ResettingTimer Percentiles([]float64) []int64 Mean() float64 Time(func()) Update(time.Duration) UpdateSince(time.Time) }
ResettingTimer is used for storing aggregated values for timers, which are reset on every flush interval.
func GetOrRegisterResettingTimer ¶
func GetOrRegisterResettingTimer(name string, r metrics.Registry) ResettingTimer
GetOrRegisterResettingTimer returns an existing ResettingTimer or constructs and registers a new StandardResettingTimer.
func NewRegisteredResettingTimer ¶
func NewRegisteredResettingTimer(name string, r metrics.Registry) ResettingTimer
NewRegisteredResettingTimer constructs and registers a new StandardResettingTimer.
func NewResettingTimer ¶
func NewResettingTimer() ResettingTimer
NewResettingTimer constructs a new StandardResettingTimer
type ResettingTimerSnapshot ¶
type ResettingTimerSnapshot struct {
// contains filtered or unexported fields
}
ResettingTimerSnapshot is a point-in-time copy of another ResettingTimer.
func (*ResettingTimerSnapshot) Mean ¶
func (t *ResettingTimerSnapshot) Mean() float64
Mean returns the mean of the snapshotted values
func (*ResettingTimerSnapshot) Percentiles ¶
func (t *ResettingTimerSnapshot) Percentiles(percentiles []float64) []int64
Percentiles returns the boundaries for the input percentiles.
func (*ResettingTimerSnapshot) Snapshot ¶
func (t *ResettingTimerSnapshot) Snapshot() ResettingTimer
Snapshot returns the snapshot.
func (*ResettingTimerSnapshot) Update ¶
func (*ResettingTimerSnapshot) Update(time.Duration)
Update panics.
func (*ResettingTimerSnapshot) UpdateSince ¶
func (*ResettingTimerSnapshot) UpdateSince(time.Time)
UpdateSince panics.
func (*ResettingTimerSnapshot) Values ¶
func (t *ResettingTimerSnapshot) Values() []int64
Values returns all values from snapshot.
type StandardResettingTimer ¶
type StandardResettingTimer struct {
// contains filtered or unexported fields
}
StandardResettingTimer is the standard implementation of a ResettingTimer. and Meter.
func (*StandardResettingTimer) Percentiles ¶
func (t *StandardResettingTimer) Percentiles([]float64) []int64
Percentiles panics.
func (*StandardResettingTimer) Snapshot ¶
func (t *StandardResettingTimer) Snapshot() ResettingTimer
Snapshot resets the timer and returns a read-only copy of its contents.
func (*StandardResettingTimer) Time ¶
func (t *StandardResettingTimer) Time(f func())
Record the duration of the execution of the given function.
func (*StandardResettingTimer) Update ¶
func (t *StandardResettingTimer) Update(d time.Duration)
Record the duration of an event.
func (*StandardResettingTimer) UpdateSince ¶
func (t *StandardResettingTimer) UpdateSince(ts time.Time)
Record the duration of an event that started at a time and ends now.
func (*StandardResettingTimer) Values ¶
func (t *StandardResettingTimer) Values() []int64
Values returns a slice with all measurements.