package cloudwatch

import "github.com/go-kit/kit/metrics/cloudwatch"

Index

Types

type CloudWatch

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

CloudWatch receives metrics observations and forwards them to CloudWatch. Create a CloudWatch object, use it to create metrics, and pass those metrics as dependencies to the components that will use them.

To regularly report metrics to CloudWatch, use the WriteLoop helper method.

func New

func New(namespace string, svc cloudwatchiface.CloudWatchAPI, logger log.Logger) *CloudWatch

New returns a CloudWatch object that may be used to create metrics. Namespace is applied to all created metrics and maps to the CloudWatch namespace. Callers must ensure that regular calls to Send are performed, either manually or with one of the helper methods.

func (*CloudWatch) NewCounter

func (cw *CloudWatch) NewCounter(name string) metrics.Counter

NewCounter returns a counter. Observations are aggregated and emitted once per write invocation.

func (*CloudWatch) NewGauge

func (cw *CloudWatch) NewGauge(name string) metrics.Gauge

NewGauge returns a gauge. Observations are aggregated and emitted once per write invocation.

func (*CloudWatch) NewHistogram

func (cw *CloudWatch) NewHistogram(name string, buckets int) metrics.Histogram

NewHistogram returns a histogram. Observations are aggregated and emitted as per-quantile gauges, once per write invocation. 50 is a good default value for buckets.

func (*CloudWatch) Send

func (cw *CloudWatch) Send() error

Send will fire an API request to CloudWatch with the latest stats for all metrics. It is preferred that the WriteLoop method is used.

func (*CloudWatch) WriteLoop

func (cw *CloudWatch) WriteLoop(c <-chan time.Time)

WriteLoop is a helper method that invokes Send every time the passed channel fires. This method blocks until the channel is closed, so clients probably want to run it in its own goroutine. For typical usage, create a time.Ticker and pass its C channel to this method.

Source Files

cloudwatch.go

Version
v0.5.0
Published
Jun 8, 2017
Platform
linux/amd64
Imports
9 packages
Last checked
1 hour ago

Tools for package owners.