reporter

package module
v0.0.0-...-dc71f85 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-metrics-cloudwatch-reporter

Build Status GoDoc

This library provides a reporter for go-metrics that will send metrics to CloudWatch. This library is based on savaki/cloudmetrics but the original implementation was largely refactored.

Usage and Configuration

This library supports the following configuration options:

import "github.com/alexliesenfeld/go-metrics-cloudwatch-reporter"

go reporter.Publish(metrics.DefaultRegistry,
    "sample-namespace",                          // namespace
    reporter.Dimensions("k1", "v1", "k2", "v2"), // allows for custom dimensions
    reporter.Interval(time.Minutes * 5),         // custom interval
    reporter.Context(context.Background()),      // enables graceful shutdown
    reporter.Percentiles([]float64{.5, .99}),    // customize percentiles for histograms and timers
    reporter.Log(os.Stderr),                     // set a log to write errors to
    reporter.Debug(os.Stdout),                   // set a log to write debug messages to
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context

func Context(ctx context.Context) func(*Publisher)

Context allows a context to be specified. When <-ctx.Done() returns; the Publisher will stop any internal go routines and return

func Debug

func Debug(w io.Writer) func(*Publisher)

Debug writes additional data to the writer specified

func Dimensions

func Dimensions(keysAndValues ...string) func(*Publisher)

Dimensions allows for user specified dimensions to be added to the post

func Interval

func Interval(interval time.Duration) func(*Publisher)

Interval allows for a custom posting interval; by default, the interval is every 1 minute

func Log

func Log(w io.Writer) func(*Publisher)

Log adds a log to the library so it can log errors

func Percentiles

func Percentiles(percentiles []float64) func(*Publisher)

Percentiles allows the reported percentiles for Histogram and Timer metrics to be customized

func Publish

func Publish(client PutMetricsClient, registry metrics.Registry, namespace string, configs ...func(*Publisher))

Publish is the main entry point to publish metrics on a recurring basis to CloudWatch

Types

type Publisher

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

type PutMetricsClient

type PutMetricsClient interface {
	PutMetricData(*cloudwatch.PutMetricDataInput) (*cloudwatch.PutMetricDataOutput, error)
}

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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