cloudwatch

package
v0.5.101 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// AwsRegion is the required AWS Region to use
	AwsRegion string

	// AwsEndpoint is the optional AWS endpoint to use
	AwsEndpoint string

	// Namespace specifies the namespace under which metrics should be published.
	Namespace string

	// PublishInterval specifies the frequency with which metrics should be published to Cloudwatch.
	PublishInterval time.Duration

	// MetricsExpiry is the period after wich the metrics will be deleted from reporting if not used.
	MetricsExpiry time.Duration

	// WithSampleCount specifies to create additional _count and _sum metrics for sample
	WithSampleCount bool

	// WithCleanup specifies to clean up published metrics
	WithCleanup bool
}

Config defines configuration options

type Publisher added in v0.4.0

type Publisher interface {
	//Publish(ctx context.Context, data []types.MetricDatum) error
	PutMetricData(ctx context.Context, params *cloudwatch.PutMetricDataInput, optFns ...func(*cloudwatch.Options)) (*cloudwatch.PutMetricDataOutput, error)
}

Publisher provides interface to publish metrics

type Sink

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

Sink provides a MetricSink that can be used with a prometheus server.

func NewSink

func NewSink(c *Config) (*Sink, error)

NewSink initializes and returns a pointer to a CloudWatch Sink using the supplied configuration, or an error if there is a problem with the configuration

func (*Sink) AddSample

func (p *Sink) AddSample(key string, val float64, tags []metrics.Tag)

AddSample is for timing information, where quantiles are used

func (*Sink) Data

func (p *Sink) Data() []types.MetricDatum

Data returns collected metrics and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.

func (*Sink) Flush

func (p *Sink) Flush(ctx context.Context) error

Flush the data to CloudWatch

func (*Sink) IncrCounter

func (p *Sink) IncrCounter(key string, val float64, tags []metrics.Tag)

IncrCounter should accumulate values

func (*Sink) Publish added in v0.4.0

func (p *Sink) Publish(ctx context.Context, data []types.MetricDatum) error

Publish metrics

func (*Sink) Run

func (p *Sink) Run(ctx context.Context)

Run starts a loop that will push metrics to Cloudwatch at the configured interval. Accepts a context.Context to support cancellation

func (*Sink) SetGauge

func (p *Sink) SetGauge(key string, val float64, tags []metrics.Tag)

SetGauge should retain the last value it is set to

Jump to

Keyboard shortcuts

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