cloudmonitoring

package
v0.0.0-...-6cce6f8 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package cloudmonitoring provides functionality to interact with the Cloud Monitoring API.

Index

Constants

View Source
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.

func ShortConstantBackOffPolicy

func ShortConstantBackOffPolicy(ctx context.Context, initial time.Duration, retries uint64) backoff.BackOffContext

ShortConstantBackOffPolicy returns a backoff policy with 15s MaxElapsedTime.

Types

type BackOffIntervals

type BackOffIntervals struct {
	LongExponential, ShortConstant time.Duration
	Retries                        uint64
}

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.

Directories

Path Synopsis
Package fake implements test fakes for the cloudmonitoring wrappers.
Package fake implements test fakes for the cloudmonitoring wrappers.

Jump to

Keyboard shortcuts

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