cloudwatch

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = "2006-01-02T15:04:05.999999-07:00"

Variables

This section is empty.

Functions

func DetermineGetMetricDataWindow

func DetermineGetMetricDataWindow(clock Clock, roundingPeriod time.Duration, length time.Duration, delay time.Duration) (time.Time, time.Time)

determineGetMetricDataWindow computes the start and end time for the GetMetricData request to AWS Always uses the wall clock time as starting point for calculations to ensure that a variety of exporter configurations will work reliably.

Types

type Client

type Client interface {
	// ListMetrics returns the list of metrics and dimensions for a given namespace
	// and metric name. Results pagination is handled automatically: the caller can
	// optionally pass a non-nil func in order to handle results pages.
	ListMetrics(ctx context.Context, namespace string, metric *model.MetricConfig, recentlyActiveOnly bool, fn func(page []*model.Metric)) error

	// GetMetricData returns the output of the GetMetricData CloudWatch API.
	// Results pagination is handled automatically.
	GetMetricData(ctx context.Context, logger logging.Logger, getMetricData []*model.CloudwatchData, namespace string, length int64, delay int64, configuredRoundingPeriod *int64) []MetricDataResult

	// GetMetricStatistics returns the output of the GetMetricStatistics CloudWatch API.
	GetMetricStatistics(ctx context.Context, logger logging.Logger, dimensions []model.Dimension, namespace string, metric *model.MetricConfig) []*model.Datapoint
}

func NewLimitedConcurrencyClient

func NewLimitedConcurrencyClient(client Client, limiter ConcurrencyLimiter) Client

type Clock

type Clock interface {
	Now() time.Time
}

Clock small interface which allows for stubbing the time.Now() function for unit testing

type ConcurrencyConfig added in v0.56.0

type ConcurrencyConfig struct {
	// PerAPIEnabled configures whether to have a limit per API call.
	PerAPILimitEnabled bool

	// SingleLimit configures the concurrency limit when using a single limiter for api calls.
	SingleLimit int

	// ListMetrics limits the number for ListMetrics API concurrent API calls.
	ListMetrics int

	// GetMetricData limits the number for GetMetricData API concurrent API calls.
	GetMetricData int

	// GetMetricStatistics limits the number for GetMetricStatistics API concurrent API calls.
	GetMetricStatistics int
}

ConcurrencyConfig configures how concurrency should be limited in a Cloudwatch API client. It allows one to pick between different limiter implementations: a single limit limiter, or one with a different limit per API call.

func (ConcurrencyConfig) NewLimiter added in v0.56.0

func (cfg ConcurrencyConfig) NewLimiter() ConcurrencyLimiter

NewLimiter creates a new ConcurrencyLimiter, according to the ConcurrencyConfig.

type ConcurrencyLimiter added in v0.56.0

type ConcurrencyLimiter interface {
	// Acquire takes one "ticket" from the concurrency limiter for op. If there's none available, the caller
	// routine will be blocked until there's room available.
	Acquire(op string)

	// Release gives back one "ticket" to the concurrency limiter identified by op. If there's one or more
	// routines waiting for one, one will be woken up.
	Release(op string)
}

ConcurrencyLimiter limits the concurrency when calling AWS CloudWatch APIs. The functions implemented by this interface follow the same as a normal semaphore, but accept and operation identifier. Some implementations might use this to keep a different semaphore, with different reentrance values, per operation.

func NewPerAPICallLimiter added in v0.56.0

func NewPerAPICallLimiter(listMetrics, getMetricData, getMetricStatistics int) ConcurrencyLimiter

NewPerAPICallLimiter creates a new PerAPICallLimiter.

func NewSingleLimiter added in v0.56.0

func NewSingleLimiter(limit int) ConcurrencyLimiter

NewSingleLimiter creates a new SingleLimiter.

type MetricDataResult

type MetricDataResult struct {
	ID string
	// A nil datapoint is a marker for no datapoint being found
	Datapoint *float64
	Timestamp time.Time
}

type TimeClock

type TimeClock struct{}

TimeClock implementation of Clock interface which delegates to Go's Time package

func (TimeClock) Now

func (tc TimeClock) Now() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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