package basic
import "go.opentelemetry.io/otel/sdk/metric/controller/basic"
Index ¶
- Constants
- Variables
- type Controller
- func New(checkpointer export.Checkpointer, opts ...Option) *Controller
- func (c *Controller) Collect(ctx context.Context) error
- func (c *Controller) ForEach(ks export.ExportKindSelector, f func(export.Record) error) error
- func (c *Controller) IsRunning() bool
- func (c *Controller) MeterProvider() metric.MeterProvider
- func (c *Controller) SetClock(clock controllerTime.Clock)
- func (c *Controller) Start(ctx context.Context) error
- func (c *Controller) Stop(ctx context.Context) error
- type Option
Constants ¶
DefaultPeriod is used for:
- the minimum time between calls to Collect() - the timeout for Export() - the timeout for Collect().
Variables ¶
ErrControllerStarted indicates that a controller was started more than once.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller organizes and synchronizes collection of metric data in both "pull" and "push" configurations. This supports two distinct modes:
- Push and Pull: Start() must be called to begin calling the exporter; Collect() is called periodically by a background thread after starting the controller.
- Pull-Only: Start() is optional in this case, to call Collect periodically. If Start() is not called, Collect() can be called manually to initiate collection
The controller supports mixing push and pull access to metric data using the export.CheckpointSet RWLock interface. Collection will be blocked by a pull request in the basic controller.
func New ¶
func New(checkpointer export.Checkpointer, opts ...Option) *Controller
New constructs a Controller using the provided checkpointer and options (including optional exporter) to configure a metric export pipeline.
func (*Controller) Collect ¶
func (c *Controller) Collect(ctx context.Context) error
Collect requests a collection. The collection will be skipped if the last collection is aged less than the configured collection period.
func (*Controller) ForEach ¶
func (c *Controller) ForEach(ks export.ExportKindSelector, f func(export.Record) error) error
ForEach gives the caller read-locked access to the current export.CheckpointSet.
func (*Controller) IsRunning ¶
func (c *Controller) IsRunning() bool
IsRunning returns true if the controller was started via Start(), indicating that the current export.CheckpointSet is being kept up-to-date.
func (*Controller) MeterProvider ¶
func (c *Controller) MeterProvider() metric.MeterProvider
MeterProvider returns a MeterProvider instance for this controller.
func (*Controller) SetClock ¶
func (c *Controller) SetClock(clock controllerTime.Clock)
SetClock supports setting a mock clock for testing. This must be called before Start().
func (*Controller) Start ¶
func (c *Controller) Start(ctx context.Context) error
Start begins a ticker that periodically collects and exports metrics with the configured interval. This is required for calling a configured Exporter (see WithExporter) and is otherwise optional when only pulling metric data.
The passed context is passed to Collect() and subsequently to asynchronous instrument callbacks. Returns an error when the controller was already started.
Note that it is not necessary to Start a controller when only pulling data; use the Collect() and ForEach() methods directly in this case.
func (*Controller) Stop ¶
func (c *Controller) Stop(ctx context.Context) error
Stop waits for the background goroutine to return and then collects and exports metrics one last time before returning. The passed context is passed to the final Collect() and subsequently to the final asynchronous instruments.
Note that Stop() will not cancel an ongoing collection or export.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is the interface that applies the value to a configuration option.
func WithCollectPeriod ¶
WithCollectPeriod sets the CollectPeriod configuration option of a Config.
func WithCollectTimeout ¶
WithCollectTimeout sets the CollectTimeout configuration option of a Config.
func WithExporter ¶
WithExporter sets the exporter configuration option of a Config.
func WithPushTimeout ¶
WithPushTimeout sets the PushTimeout configuration option of a Config.
func WithResource ¶
WithResource sets the Resource configuration option of a Config by merging it with the Resource configuration in the environment.
Source Files ¶
config.go controller.go
- Version
- v0.21.0
- Published
- Jun 18, 2021
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 1 hour ago –
Tools for package owners.