Documentation ¶
Overview ¶
Package cloudmonitoring provides functionality to interact with the Cloud Monitoring API.
Index ¶
- Constants
- func CreateTimeSeriesWithRetry(ctx context.Context, client TimeSeriesCreator, ...) error
- func LongExponentialBackOffPolicy(ctx context.Context, initial time.Duration, retries uint64, ...) backoff.BackOffContext
- func LongExponentialBackOffPolicyForProcessMetrics(ctx context.Context, initial time.Duration, retries uint64, ...) backoff.BackOffContext
- func QueryTimeSeriesWithRetry(ctx context.Context, client TimeSeriesQuerier, req *mpb.QueryTimeSeriesRequest, ...) ([]*mrpb.TimeSeriesData, error)
- func SendTimeSeries(ctx context.Context, timeSeries []*mrpb.TimeSeries, ...) (sent, batchCount int, err error)
- func ShortConstantBackOffPolicy(ctx context.Context, initial time.Duration, retries uint64) backoff.BackOffContext
- type BackOffIntervals
- type TimeSeriesCreator
- type TimeSeriesQuerier
Constants ¶
const ( DefaultLongExponentialBackOffInterval = 2 * time.Second DefaultShortConstantBackOffInterval = 5 * time.Second )
Defaults for the different back off intervals.
Variables ¶
This section is empty.
Functions ¶
func CreateTimeSeriesWithRetry ¶
func CreateTimeSeriesWithRetry(ctx context.Context, client TimeSeriesCreator, req *mpb.CreateTimeSeriesRequest, bo *BackOffIntervals) error
CreateTimeSeriesWithRetry decorates TimeSeriesCreator.CreateTimeSeries with a retry mechanism.
func LongExponentialBackOffPolicy ¶
func LongExponentialBackOffPolicy(ctx context.Context, initial time.Duration, retries uint64, maxElapsedTime time.Duration, maxInterval time.Duration) backoff.BackOffContext
LongExponentialBackOffPolicy returns a backoff policy with exponential backoff.
func LongExponentialBackOffPolicyForProcessMetrics ¶
func LongExponentialBackOffPolicyForProcessMetrics(ctx context.Context, initial time.Duration, retries uint64, maxElapsedTime time.Duration, maxInterval time.Duration) backoff.BackOffContext
LongExponentialBackOffPolicyForProcessMetrics returns a backoff policy with exponential backoff.
func QueryTimeSeriesWithRetry ¶
func QueryTimeSeriesWithRetry(ctx context.Context, client TimeSeriesQuerier, req *mpb.QueryTimeSeriesRequest, bo *BackOffIntervals) ([]*mrpb.TimeSeriesData, error)
QueryTimeSeriesWithRetry decorates TimeSeriesQuerier.QueryTimeSeries with a retry mechanism.
func SendTimeSeries ¶
func SendTimeSeries(ctx context.Context, timeSeries []*mrpb.TimeSeries, timeSeriesCreator TimeSeriesCreator, bo *BackOffIntervals, projectID string) (sent, batchCount int, err error)
SendTimeSeries sends all the time series objects to cloud monitoring. maxTSPerRequest is used as an upper limit to batch send time series values per request. If a cloud monitoring API call fails even after retries, the remaining measurements are discarded.
Types ¶
type BackOffIntervals ¶
BackOffIntervals holds the initial intervals for the different back off mechanisms.
func NewBackOffIntervals ¶
func NewBackOffIntervals(longExponential, shortConstant time.Duration) *BackOffIntervals
NewBackOffIntervals is a constructor for the back off intervals.
func NewDefaultBackOffIntervals ¶
func NewDefaultBackOffIntervals() *BackOffIntervals
NewDefaultBackOffIntervals is a default constructor, utilizing the default back off intervals.
func NoBackOff ¶
func NoBackOff() *BackOffIntervals
NoBackOff is a constructor for the back off intervals with no backoff.
type TimeSeriesCreator ¶
type TimeSeriesCreator interface {
CreateTimeSeries(ctx context.Context, req *mpb.CreateTimeSeriesRequest, opts ...gax.CallOption) error
}
TimeSeriesCreator provides an easily testable translation to the cloud monitoring API.
type TimeSeriesQuerier ¶
type TimeSeriesQuerier interface {
QueryTimeSeries(ctx context.Context, req *mpb.QueryTimeSeriesRequest, opts ...gax.CallOption) ([]*mrpb.TimeSeriesData, error)
}
TimeSeriesQuerier provides an easily testable translation to the cloud monitoring API.