bridge

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNonMonotonicValue = errors.New("unexpected non-monotonic value")

ErrNonMonotonicValue is a base error cause returned when a negative value is added to an increase-only Counter.

View Source
var ErrUnsupportedInstrument = errors.New("unsupported instrument")

ErrUnsupportedInstrument is used to signal that an instrument cannot be created by a Meter because the instrument kind and number kind together are not supported.

Functions

func DefaultBucketer added in v0.4.0

func DefaultBucketer(desc sdkapi.Descriptor) tally.Buckets

DefaultBucketer is a HistogramBucketer that gives a hardcoded set of default buckets.

func KVsToTags

func KVsToTags(kvs []attribute.KeyValue) map[string]string

KVsToTags converts a slice of otel key-value pairs to a Tally tag set.

func NewMeterProvider

func NewMeterProvider(scope tally.Scope, opts ...Opt) metric.MeterProvider

NewMeterProvider creates a new MeterProvider wrapping the provided tally.Scope.

Types

type Counter

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

Counter implements the sdkapi.SyncImpl interface wrapping a tally.Counter

func NewCounter

func NewCounter(desc sdkapi.Descriptor, scope tally.Scope) *Counter

NewCounter instantiates a new Counter that uses the provided scope as its base scope.

func (*Counter) Descriptor

func (c *Counter) Descriptor() sdkapi.Descriptor

Descriptor observes this Counter's Descriptor object

func (*Counter) Implementation

func (c *Counter) Implementation() interface{}

Implementation is unused

func (*Counter) RecordOne

func (c *Counter) RecordOne(
	ctx context.Context,
	n number.Number,
	labels []attribute.KeyValue,
)

RecordOne increments this counter by the provided value. If this Counter is configured to be an UpDownCounter then negative values are allowed.

func (*Counter) RecordOneInScope

func (c *Counter) RecordOneInScope(
	ctx context.Context,
	scope tally.Scope,
	n number.Number,
)

RecordOneInScope is used to record a value when the scope can be provided by the caller. This is only known to be the case during Meter batch recordings.

type Histogram

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

Histogram is a sdkapi.SyncImpl implementation that bridges between an OTEL Histogram and a Tally Histogram.

func NewHistogram

func NewHistogram(
	desc sdkapi.Descriptor,
	scope tally.Scope,
	buckets tally.Buckets,
) *Histogram

NewHistogram instantiates a new Histogram that uses the proved scope and bucket configuration.

func (*Histogram) Descriptor

func (h *Histogram) Descriptor() sdkapi.Descriptor

Descriptor observes this Histogram's Descriptor object

func (*Histogram) Implementation

func (h *Histogram) Implementation() interface{}

Implementation is unused

func (*Histogram) RecordOne

func (h *Histogram) RecordOne(
	ctx context.Context,
	n number.Number,
	labels []attribute.KeyValue,
)

RecordOne adds a value to this histogram.

func (*Histogram) RecordOneInScope

func (h *Histogram) RecordOneInScope(
	ctx context.Context,
	scope tally.Scope,
	n number.Number,
)

RecordOneInScope is used to record a value when the scope can be provided by the caller. This is only known to be the case during Meter batch recordings.

type HistogramBucketer

type HistogramBucketer func(sdkapi.Descriptor) tally.Buckets

HistogramBucketer maps metric metadata to a tally.Buckets instance. This is necessary because OTEL does not have a way to indicate bucket confguration at histogram creation time.

type MeterImpl

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

MeterImpl is an implementation of sdkapi.MeterImpl that uses Tally and wraps a tally.Scope

func NewMeterImpl

func NewMeterImpl(scope tally.Scope, buckets HistogramBucketer) *MeterImpl

NewMeterImpl instantiates a MeterImpl wrapping the provided scope and using the provided bucket factory to configure buckets for histograms.

func (*MeterImpl) NewAsyncInstrument

func (m *MeterImpl) NewAsyncInstrument(
	desc sdkapi.Descriptor,
	runner sdkapi.AsyncRunner,
) (sdkapi.AsyncImpl, error)

NewAsyncInstrument is required by the sdkapi.MeterImpl interface but no asynchronous instruments are supported because Tally doesn't support them.

func (*MeterImpl) NewSyncInstrument

func (m *MeterImpl) NewSyncInstrument(
	desc sdkapi.Descriptor,
) (sdkapi.SyncImpl, error)

NewSyncInstrument creates new SyncInstrument objects to support OTEL metric instruments. Supported instruments are Counter (int64 only), UpDownCounter (int64 only), Histogram. If a requested instrument is not supported the error returned here will satisfy errors.Is(err, ErrorUnsupportedInstrument).

func (*MeterImpl) RecordBatch

func (m *MeterImpl) RecordBatch(
	ctx context.Context,
	labels []attribute.KeyValue,
	measurements ...metric.Measurement,
)

RecordBatch records multiple measurements to multiple instruments in a single call.

type MeterProvider

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

MeterProvider is an implementation of metric.Meterprovider wrapping a tally.Scope.

func (*MeterProvider) Meter

func (p *MeterProvider) Meter(
	instrumentationName string,
	opts ...metric.MeterOption,
) metric.Meter

Meter creates a new metric.Meter implementation that wraps a tally.Scope that is a sub-scope of the scope provided to this MeterProvider at construction time.

type MeterScoper added in v0.5.0

type MeterScoper func(nameParts []string, baseScope tally.Scope) tally.Scope

MeterScoper is a factory for scopes to be used in a Meter given a meter name and a base scope.

type Opt

type Opt func(*MeterProvider)

Opt is the type for optional arguments to a MeterProvider.

func WithHistogramBucketer

func WithHistogramBucketer(f HistogramBucketer) Opt

WithHistogramBucketer wraps a histogram bucket factory into a MeterProvider option

func WithMeterScoper added in v0.5.0

func WithMeterScoper(f MeterScoper) Opt

WithMeterScoper provides a MeterScoper to a MeterProvider at construction time

func WithScopeNameSeparator added in v0.6.0

func WithScopeNameSeparator(s string) Opt

WithScopeNameSeparator provides a string to a MeterProvider at construction time to be used in splitting child Meter names into scope names.

Jump to

Keyboard shortcuts

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