package push

import "go.opentelemetry.io/otel/sdk/metric/controller/push"

Index

Types

type Clock

type Clock interface {
	Now() time.Time
	Ticker(time.Duration) Ticker
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller organizes a periodic push of metric data.

func New

func New(batcher export.Batcher, exporter export.Exporter, period time.Duration) *Controller

New constructs a Controller, an implementation of metric.Provider, using the provided batcher, exporter, and collection period to configure an SDK with periodic collection. The batcher itself is configured with the aggregation selector policy.

If the Exporter implements the export.LabelEncoder interface, the exporter will be used as the label encoder for the SDK itself, otherwise the SDK will be configured with the default label encoder.

func (*Controller) Meter

func (c *Controller) Meter(_ string) metric.Meter

Meter returns a named Meter, satisifying the metric.Provider interface.

func (*Controller) SetClock

func (c *Controller) SetClock(clock Clock)

SetClock supports setting a mock clock for testing. This must be called before Start().

func (*Controller) SetErrorHandler

func (c *Controller) SetErrorHandler(errorHandler sdk.ErrorHandler)

func (*Controller) Start

func (c *Controller) Start()

Start begins a ticker that periodically collects and exports metrics with the configured interval.

func (*Controller) Stop

func (c *Controller) Stop()

Stop waits for the background goroutine to return and then collects and exports metrics one last time before returning.

type Ticker

type Ticker interface {
	Stop()
	C() <-chan time.Time
}

Source Files

push.go

Version
v0.2.3
Published
Mar 4, 2020
Platform
js/wasm
Imports
6 packages
Last checked
1 hour ago

Tools for package owners.