collector

package
v0.0.0-...-3af15b6 Latest Latest
Warning

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

Go to latest
Published: May 12, 2016 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	// PauseDur represents the interval inbetween each set of stats output.
	// Defaults to 10 seconds.
	PauseDur time.Duration

	// EnableCPU determines whether CPU statisics will be output. Defaults to true.
	EnableCPU bool

	// EnableMem determines whether memory statistics will be output. Defaults to true.
	EnableMem bool

	// EnableGC determines whether garbage collection statistics will be output. EnableMem
	// must also be set to true for this to take affect. Defaults to true.
	EnableGC bool

	// Done, when closed, is used to signal Collector that is should stop collecting
	// statistics and the Run function should return. If Done is set, upon shutdown
	// all gauges will be sent a final zero value to reset their values to 0.
	Done <-chan struct{}
	// contains filtered or unexported fields
}

Collector implements the periodic grabbing of informational data from the runtime package and outputting the values to a GaugeFunc.

func New

func New(gaugeFunc GaugeFunc) *Collector

New creates a new Collector that will periodically output statistics to gaugeFunc. It will also set the values of the exported fields to the described defaults. The values of the exported defaults can be changed at any point before Run is called.

func (*Collector) Run

func (c *Collector) Run()

Run gathers statistics from package runtime and outputs them to the configured GaugeFunc every PauseDur. This function will not return until Done has been closed (or never if Done is nil), therefore it should be called in its own goroutine.

type GaugeFunc

type GaugeFunc func(key string, val uint64)

GaugeFunc is an interface that implements the setting of a gauge value in a stats system. It should be expected that key will contain multiple parts separated by the '.' character in the form used by statsd (e.x. "mem.heap.alloc")

Jump to

Keyboard shortcuts

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