metrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package metrics provides a simple API for sending value and counter metrics through the dropsonde system.

Use

See the documentation for package dropsonde for configuration details.

Importing package dropsonde and initializing will initial this package. To send metrics use

metrics.SendValue(name, value, unit)

for sending known quantities, and

metrics.IncrementCounter(name)

to increment a counter. (Note that the value of the counter is maintained by the receiver of the counter events, not the application that includes this package.)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToCounter

func AddToCounter(name string, delta uint64) error

AddToCounter sends an event to increment the named counter by the specified (positive) delta. Maintaining the value of the counter is the responsibility of the receiver, as with IncrementCounter.

func BatchAddCounter

func BatchAddCounter(name string, delta uint64)

BatchAddCounter adds delta to a counter but, unlike AddCounter, does not emit a CounterEvent for each add; instead, the adds are batched and a single CounterEvent is sent after the timeout.

func BatchIncrementCounter

func BatchIncrementCounter(name string)

BatchIncrementCounter increments a counter but, unlike IncrementCounter, does not emit a CounterEvent for each increment; instead, the increments are batched and a single CounterEvent is sent after the timeout.

func Close

func Close()

Closes the metrics system and flushes any batch metrics.

func ContainerMetric

func ContainerMetric(appID string, instance int32, cpu float64, mem, disk uint64) metric_sender.ContainerMetricChainer

ContainerMetric creates a container metric that can be manipulated via cascading calls and then sent.

func Counter

func Counter(name string) metric_sender.CounterChainer

Counter creates a counter event that can be manipulated via cascading calls and then sent via Increment or Add.

func IncrementCounter

func IncrementCounter(name string) error

IncrementCounter sends an event to increment the named counter by one. Maintaining the value of the counter is the responsibility of the receiver of the event, not the process that includes this package.

func Initialize

func Initialize(ms MetricSender, mb MetricBatcher)

Initialize prepares the metrics package for use with the automatic Emitter.

func Send

func Send(ev events.Event) error

Send sends an events.Event.

func SendContainerMetric

func SendContainerMetric(applicationId string, instanceIndex int32, cpuPercentage float64, memoryBytes uint64, diskBytes uint64) error

SendContainerMetric sends a metric that records resource usage of an app in a container. The container is identified by the applicationId and the instanceIndex. The resource metrics are CPU percentage, memory and disk usage in bytes. Returns an error if one occurs when sending the metric.

func SendValue

func SendValue(name string, value float64, unit string) error

SendValue sends a value event for the named metric. See http://metrics20.org/spec/#units for the specifications on allowed units.

func Value

func Value(name string, value float64, unit string) metric_sender.ValueChainer

Value creates a value metric that can be manipulated via cascading calls and then sent.

Types

type MetricBatcher

type MetricBatcher interface {
	BatchIncrementCounter(name string)
	BatchAddCounter(name string, delta uint64)
	Close()
}

type MetricSender

type MetricSender interface {
	Send(event events.Event) error

	// new chanining functions
	Value(name string, value float64, unit string) metric_sender.ValueChainer
	ContainerMetric(appID string, instance int32, cpu float64, mem, disk uint64) metric_sender.ContainerMetricChainer
	Counter(name string) metric_sender.CounterChainer

	// legacy functions
	SendValue(name string, value float64, unit string) error
	IncrementCounter(name string) error
	AddToCounter(name string, delta uint64) error
	SendContainerMetric(applicationId string, instanceIndex int32, cpuPercentage float64, memoryBytes uint64, diskBytes uint64) error
}

Jump to

Keyboard shortcuts

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