metrics

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectProcessMetrics

func CollectProcessMetrics()

func CollectProcessStats

func CollectProcessStats(stats *ProcessStats) error

func NewMAMeter

func NewMAMeter() metrics.Meter

NewMAMeter constructs a new StandardMAMeter and launches a goroutine. Be sure to call Stop() once the meter is of no use to allow for garbage collection.

func NewRegisteredMAMeter

func NewRegisteredMAMeter(name string, r metrics.Registry) metrics.Meter

NewMeter constructs and registers a new StandardMeter and launches a goroutine. Be sure to unregister the meter from the registry once it is of no use to allow for garbage collection.

Types

type MAMeterSnapshot

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

MAMeterSnapshot is a read-only copy of another Meter.

func (*MAMeterSnapshot) Count

func (m *MAMeterSnapshot) Count() int64

Count returns the count of events at the time the snapshot was taken.

func (*MAMeterSnapshot) Mark

func (*MAMeterSnapshot) Mark(n int64)

Mark panics.

func (*MAMeterSnapshot) Rate1

func (m *MAMeterSnapshot) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.

func (*MAMeterSnapshot) Rate15

func (m *MAMeterSnapshot) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.

func (*MAMeterSnapshot) Rate5

func (m *MAMeterSnapshot) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.

func (*MAMeterSnapshot) RateMean

func (m *MAMeterSnapshot) RateMean() float64

RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.

func (*MAMeterSnapshot) Snapshot

func (m *MAMeterSnapshot) Snapshot() metrics.Meter

Snapshot returns the snapshot.

func (*MAMeterSnapshot) Stop

func (m *MAMeterSnapshot) Stop()

Stop is a no-op.

type ProcessStats

type ProcessStats struct {
	CpuUserTime   int64 // Cpu use time(/proc/[pid]/stat utime)
	CpuSystemTime int64 // Cpu use time(/proc/[pid]/stat stime)
	CurrentTime   int64 // Current time

	VirtualMem int64 // Virtual memory size
	RssMem     int64 // Resident memory size

	DiskReadCount  int64 // Number of read operations executed
	DiskReadBytes  int64 // Total number of bytes read
	DiskWriteCount int64 // Number of write operations executed
	DiskWriteBytes int64 // Total number of byte written
}

type StandardMA

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

StandardMA is the standard implementation of an MA and tracks the number of uncounted events and processes them on each tick. It uses the sync/atomic package to manage uncounted events.

func NewMA1

func NewMA1() *StandardMA

func NewMA15

func NewMA15() *StandardMA

func NewMA5

func NewMA5() *StandardMA

func (*StandardMA) Rate

func (a *StandardMA) Rate() float64

Rate returns the moving average rate of events per second.

func (*StandardMA) Tick

func (a *StandardMA) Tick()

Tick ticks the clock to update the moving average. It assumes it is called every five seconds.

func (*StandardMA) Update

func (a *StandardMA) Update(n int64)

Update adds n uncounted events.

type StandardMAMeter

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

StandardMaMeter is the standard ma implementation of a Meter.

func (*StandardMAMeter) Count

func (m *StandardMAMeter) Count() int64

Count returns the number of events recorded.

func (*StandardMAMeter) Mark

func (m *StandardMAMeter) Mark(n int64)

Mark records the occurance of n events.

func (*StandardMAMeter) Rate1

func (m *StandardMAMeter) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second.

func (*StandardMAMeter) Rate15

func (m *StandardMAMeter) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second.

func (*StandardMAMeter) Rate5

func (m *StandardMAMeter) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second.

func (*StandardMAMeter) RateMean

func (m *StandardMAMeter) RateMean() float64

RateMean returns the meter's mean rate of events per second.

func (*StandardMAMeter) Snapshot

func (m *StandardMAMeter) Snapshot() metrics.Meter

Snapshot returns a read-only copy of the meter.

func (*StandardMAMeter) Stop

func (m *StandardMAMeter) Stop()

Stop stops the meter, Mark() will be a no-op if you use it after being stopped.

Jump to

Keyboard shortcuts

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