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 Config

type Config struct {
	// ErrorHandler is the function called when the Controller encounters an error.
	//
	// This option can be overridden after instantiation of the Controller
	// with the `SetErrorHandler` method.
	ErrorHandler sdk.ErrorHandler

	// Resource is the OpenTelemetry resource associated with all Meters
	// created by the Controller.
	Resource *resource.Resource
}

Config contains configuration for a push Controller.

type Controller

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

Controller organizes a periodic push of metric data.

func New

func New(integrator export.Integrator, exporter export.Exporter, period time.Duration, opts ...Option) *Controller

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

func (*Controller) Meter

func (c *Controller) Meter(name 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 Option

type Option interface {
	// Apply sets the Option value of a Config.
	Apply(*Config)
}

Option is the interface that applies the value to a configuration option.

func WithErrorHandler

func WithErrorHandler(fn sdk.ErrorHandler) Option

WithErrorHandler sets the ErrorHandler configuration option of a Config.

func WithResource

func WithResource(r *resource.Resource) Option

WithResource sets the Resource configuration option of a Config.

type Ticker

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

Source Files

config.go push.go

Version
v0.5.0
Published
May 14, 2020
Platform
linux/amd64
Imports
8 packages
Last checked
8 minutes ago

Tools for package owners.