Documentation ¶
Index ¶
Constants ¶
const DefaultInterval = 30 * time.Second
const DefaultTimeout = DefaultInterval
Variables ¶
var ErrAlreadyShutdown = fmt.Errorf("provider was already shut down")
var ErrAlreadyUnregistered = fmt.Errorf("callback was already unregistered")
var ErrMultipleReaderRegistration = fmt.Errorf("reader has multiple registrations")
Functions ¶
This section is empty.
Types ¶
type ManualReader ¶
ManualReader is a a simple Reader that allows an application to read metrics on demand. It simply stores the Producer interface provided through registration. Flush and Shutdown are no-ops.
func NewManualReader ¶
func NewManualReader(name string) *ManualReader
NewManualReader returns an Reader that stores the Producer for manual use and returns a configurable `name` as its String(),
func (*ManualReader) ForceFlush ¶
func (mr *ManualReader) ForceFlush(context.Context) error
ForceFlush is a no-op, always returns nil.
func (*ManualReader) Register ¶
func (mr *ManualReader) Register(p Producer)
Register stores the Producer which enables the caller to read metrics on demand.
func (*ManualReader) Shutdown ¶
func (mr *ManualReader) Shutdown(context.Context) error
Shutdown is a no-op, always returns nil.
func (*ManualReader) String ¶
func (mr *ManualReader) String() string
String returns the name of this ManualReader.
type MeterProvider ¶
type MeterProvider struct { embedded.MeterProvider // contains filtered or unexported fields }
MeterProvider handles the creation and coordination of Meters. All Meters created by a MeterProvider will be associated with the same Resource, have the same Views applied to them, and have their produced metric telemetry passed to the configured Readers.
func NewMeterProvider ¶
func NewMeterProvider(options ...Option) *MeterProvider
NewMeterProvider returns a new and configured MeterProvider.
By default, the returned MeterProvider is configured with the default Resource and no Readers. Readers cannot be added after a MeterProvider is created. This means the returned MeterProvider, one created with no Readers, will be perform no operations.
func (*MeterProvider) ForceFlush ¶
func (mp *MeterProvider) ForceFlush(ctx context.Context) error
ForceFlush flushes all pending telemetry.
This method honors the deadline or cancellation of ctx. An appropriate error will be returned in these situations. There is no guaranteed that all telemetry be flushed or all resources have been released in these situations.
This method is safe to call concurrently.
func (*MeterProvider) Meter ¶
func (mp *MeterProvider) Meter(name string, options ...metric.MeterOption) metric.Meter
Meter returns a Meter with the given name and configured with options.
The name should be the name of the instrumentation scope creating telemetry. This name may be the same as the instrumented code only if that code provides built-in instrumentation.
If name is empty, the default (go.opentelemetry.io/otel/sdk/meter) will be used.
Calls to the Meter method after Shutdown has been called will return Meters that perform no operations.
This method is safe to call concurrently.
func (*MeterProvider) Shutdown ¶
func (mp *MeterProvider) Shutdown(ctx context.Context) error
Shutdown shuts down the MeterProvider flushing all pending telemetry and releasing any held computational resources.
This call is idempotent. The first call will perform all flush and releasing operations. Subsequent calls will perform no action.
Measurements made by instruments from meters this MeterProvider created will not be exported after Shutdown is called.
This method honors the deadline or cancellation of ctx. An appropriate error will be returned in these situations. There is no guaranteed that all telemetry be flushed or all resources have been released in these situations.
This method is safe to call concurrently.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies a configuration option value to a MeterProvider.
func WithPerformance ¶ added in v1.13.1
func WithPerformance(perf sdkinstrument.Performance) Option
WithPerformance supports modifying performance settings.
func WithReader ¶
WithReader associates a new Reader and associated View options with a new MeterProvider
func WithResource ¶
WithResource associates a Resource with a new MeterProvider.
type PeriodicReader ¶
type PeriodicReader struct {
// contains filtered or unexported fields
}
PeriodicReader is an implementation of Reader that manages periodic exporter, flush, and shutdown. This implementation re-uses data from one collection to the next, to lower memory costs.
func NewPeriodicReader ¶
func NewPeriodicReader(exporter PushExporter, interval time.Duration, opts ...PeriodicReaderOption) *PeriodicReader
NewPeriodicReader constructs a PeriodicReader from a push-based exporter given an interval.
func (*PeriodicReader) ForceFlush ¶
func (pr *PeriodicReader) ForceFlush(ctx context.Context) error
ForceFlush immediately waits for an existing collection, otherwise immediately begins collection without regards to timing and calls ForceFlush with current data. There is no automatic timeout; to apply one, use context.WithTimeout.
func (*PeriodicReader) Register ¶
func (pr *PeriodicReader) Register(producer Producer)
Register starts the periodic export loop.
func (*PeriodicReader) Shutdown ¶
func (pr *PeriodicReader) Shutdown(ctx context.Context) error
Shutdown stops the export loop, canceling its Context, and waits for it to return. Then it issues a ShutdownMetrics with final data. There is no automatic timeout; to apply one, use context.WithTimeout.
func (*PeriodicReader) String ¶
func (pr *PeriodicReader) String() string
String returns the exporter name and the configured interval.
type PeriodicReaderOption ¶
type PeriodicReaderOption func(*PeriodicReader)
func WithTimeout ¶
func WithTimeout(d time.Duration) PeriodicReaderOption
type Producer ¶
type Producer interface { // Produce returns metrics from a single collection. // // Produce may be called concurrently. // // The `in` parameter supports re-use of memory from // one collection to the next. Callers that pass `in` // will write metrics into the same slices and structs. // // When `in` is nil, a new Metrics object is returned. Produce(in *data.Metrics) data.Metrics }
Producer is the interface used to perform collection by the reader.
type PushExporter ¶
type PushExporter interface { // String is the name used in errors related to this exporter/reader. String() string // ExportMetrics is called periodically with data collected // from the Producer. ExportMetrics(context.Context, data.Metrics) error // ShutdownMetrics is called when the user calls Shutdown with // final data collected from the Producer. ShutdownMetrics(context.Context, data.Metrics) error // ForceFlushMetrics is called when the user calls ForceFlush // with data collected from the Producer. ForceFlushMetrics(context.Context, data.Metrics) error }
PushExporter is an interface for push-based exporters.
type Reader ¶
type Reader interface { // String describes this reader. String() string // Register is called when the SDK is fully // configured. The Producer passed allows the // Reader to begin collecting metrics using its // Produce() method. Register(Producer) // ForceFlush is called when MeterProvider.ForceFlush() is called. ForceFlush(context.Context) error // Shutdown is called when MeterProvider.Shutdown() is called. Shutdown(context.Context) error }
Reader is the interface used between the SDK and an exporter. Control flow is bi-directional through the Reader, since the SDK initiates ForceFlush and Shutdown while the Reader initiates collection. The Register() method here informs the Reader that it can begin reading, signaling the start of bi-directional control flow.
Typically, push-based exporters that are periodic will implement PeroidicExporter themselves and construct a PeriodicReader to satisfy this interface.
Pull-based exporters will typically implement Register themselves, since they read on demand.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
package aggregator defines the interface used between the SDK and various kinds of aggregation.
|
package aggregator defines the interface used between the SDK and various kinds of aggregation. |
example
module
|
|
exporters
|
|
internal
|
|
doevery
package doevery provides primitives for per-call-site rate-limiting.
|
package doevery provides primitives for per-call-site rate-limiting. |
viewstate
package viewstate implements a View compiler, which combines information about the instrument kind (especially synchronous vs.
|
package viewstate implements a View compiler, which combines information about the instrument kind (especially synchronous vs. |