counter

package
v0.0.0-...-df27b73 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2018 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusCountMetric is the name of the custom cumulative metric
	// to which status counts are written.
	StatusCountMetric = "custom.googleapis.com/http_response_count"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CounterMetricT

type CounterMetricT interface {
	Create() error
	Increment(map[string]int64) error
	ResetTime() time.Time
}

CounterMetricT provides an interface implemented by all cumulative counter metrics. Can be used, for example, to implement mock counters for tests.

type CreateMetricCallbackT

type CreateMetricCallbackT func(string, *monitoring.MetricDescriptor) error

type CreateTimeSeriesCallbackT

type CreateTimeSeriesCallbackT func(string, *monitoring.CreateTimeSeriesRequest) error

type StatusCounter

type StatusCounter struct {

	// Public for injection from unit tests:
	CreateMetricCallback     CreateMetricCallbackT
	CreateTimeSeriesCallback CreateTimeSeriesCallbackT
	// contains filtered or unexported fields
}

StatusCounter implements CounterMetricT for HTTP respone status code counts.

func NewStatusCounter

func NewStatusCounter(project string, resource *monitoring.MonitoredResource, service *monitoring.Service) *StatusCounter

NewStatusCounter creats a StatusCounter associated with the provided project and MonitoredResource, which will write timeseries values via the provided service.

func (*StatusCounter) Create

func (c *StatusCounter) Create() error

Create will create the custom HTTP response status count metric in Stackdriver.

func (*StatusCounter) Increment

func (c *StatusCounter) Increment(counts map[string]int64) error

Increment will accumulate status code count deltas from the supplied map and write a new timeseries point.

func (*StatusCounter) ResetTime

func (c *StatusCounter) ResetTime() time.Time

ResetTime returns the reset time of the counter metric (i.e. time since which counts have been accumulated).

Jump to

Keyboard shortcuts

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