package cloudwatch2
import "github.com/go-kit/kit/metrics/cloudwatch2"
Package cloudwatch2 emits all data as a StatisticsSet (rather than a singular Value) to CloudWatch via the aws-sdk-go-v2 SDK.
Index ¶
- type CloudWatch
- func New(namespace string, svc CloudWatchAPI, options ...Option) *CloudWatch
- func (cw *CloudWatch) NewCounter(name string) metrics.Counter
- func (cw *CloudWatch) NewGauge(name string) metrics.Gauge
- func (cw *CloudWatch) NewHistogram(name string) metrics.Histogram
- func (cw *CloudWatch) Send() error
- func (cw *CloudWatch) WriteLoop(ctx context.Context, c <-chan time.Time)
- type CloudWatchAPI
- type Counter
- type Option
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 CloudWatchAPI, options ...Option) *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 an gauge. Under the covers, there is no distinctions in CloudWatch for how Counters/Histograms/Gauges are reported, so this just wraps a cloudwatch2.Counter.
func (*CloudWatch) NewHistogram ¶
func (cw *CloudWatch) NewHistogram(name string) metrics.Histogram
NewHistogram returns a histogram. Under the covers, there is no distinctions in CloudWatch for how Counters/Histograms/Gauges are reported, so this just wraps a cloudwatch2.Counter.
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(ctx context.Context, c <-chan time.Time)
WriteLoop is a helper method that invokes Send every time the passed channel fires. This method blocks until ctx is canceled, 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.
type CloudWatchAPI ¶
type CloudWatchAPI interface { PutMetricData(ctx context.Context, params *cloudwatch.PutMetricDataInput, optFns ...func(*cloudwatch.Options)) (*cloudwatch.PutMetricDataOutput, error) }
CloudWatchAPI is an interface that defines the set of Amazon CloudWatch API operations required by CloudWatch.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a counter. Observations are forwarded to a node object, and aggregated per timeseries.
func (*Counter) Add ¶
Add implements metrics.Counter.
func (*Counter) With ¶
With implements metrics.Counter.
type Option ¶
type Option func(*CloudWatch)
Option is a function adapter to change config of the CloudWatch struct
func WithConcurrentRequests ¶
WithConcurrentRequests sets the upper limit on how many cloudwatch.PutMetricDataRequest may be under way at any given time. If n is greater than 20, 20 is used. By default, the max is set at 10 concurrent requests.
func WithLogger ¶
WithLogger sets the Logger that will receive error messages generated during the WriteLoop. By default, no logger is used.
Source Files ¶
- Version
- v0.13.0 (latest)
- Published
- May 29, 2023
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 2 days ago –
Tools for package owners.