otel

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Overview

Package otel is a wrapper around Open-Telemetry's API for submitting metrics.

This satisfies the go-kit metrics Provider type.

Index

Constants

View Source
const DefaultAgentEndpoint = "0.0.0.0:55680"

DefaultAgentEndpoint is a default exporter endpoint that points to a local otel collector.

Variables

View Source
var (
	// ErrExporterNil is returned if an exporter is required, but is not passed in.
	ErrExporterNil = errors.New("exporter cannot be nil")
	// ErrAggregatorNil is returned if an aggregator is required, but is not passed in.
	ErrAggregatorNil = errors.New("aggregator cannot be nil")
	// ErrEndpointNil is returned if an endpoint is required, but is not passed in.
	ErrEndpointNil = errors.New("endpoint cannot be nil")
)

Functions

func New

func New(ctx context.Context, serviceName string, opts ...Option) (xmetrics.Provider, error)

New returns a new, unstarted Provider. Use its Start() method to start and establish a connection with its exporter's collector agent.

func NewHTTPClient added in v0.0.34

func NewHTTPClient(url *url.URL, opts ...otlpmetrichttp.Option) otlpmetric.Client

NewHTTPClient creates a new HTTP client for exporting otel metrics.

Types

type Counter

type Counter struct {
	metric.Float64Counter
	// contains filtered or unexported fields
}

Counter is a counter.

func (*Counter) Add

func (c *Counter) Add(delta float64)

Add implements metrics.Counter.

func (*Counter) With

func (c *Counter) With(labelValues ...string) metrics.Counter

With implements metrics.Counter.

type Gauge

type Gauge struct {
	*generic.Gauge
	// contains filtered or unexported fields
}

Gauge is a gauge.

func (*Gauge) Add

func (g *Gauge) Add(delta float64)

Add implements metrics.Gauge.

func (*Gauge) Set

func (g *Gauge) Set(value float64)

Set implements metrics.Gauge.

func (*Gauge) With

func (g *Gauge) With(labelValues ...string) metrics.Gauge

With implements metrics.Gauge.

type Histogram

type Histogram struct {
	metric.Float64Histogram
	// contains filtered or unexported fields
}

Histogram is a histogram.

func (*Histogram) Observe

func (h *Histogram) Observe(value float64)

Observe implements metrics.Histogram.

func (*Histogram) With

func (h *Histogram) With(labelValues ...string) metrics.Histogram

With implements metrics.Histogram.

type Option

type Option func(*Provider) error

Option is used for optional arguments when initializing Provider.

func WithAggregator

func WithAggregator(agg metric.AggregatorSelector) Option

WithAggregator initializes the Provider with an aggregator used by its controller.

func WithAttributes

func WithAttributes(attributes ...attribute.KeyValue) Option

WithAttributes initializes a serviceNameResource with attributes. If a resource already exists, a new resource is created by merging the two resources.

func WithCloudAttribute added in v0.0.33

func WithCloudAttribute(cloud string) Option

WithCloudAttribute adds the "cloud" attribute.

func WithDefaultAggregator

func WithDefaultAggregator() Option

WithDefaultAggregator initializes the Provider with a default aggregator.

func WithDefaultEndpointExporter

func WithDefaultEndpointExporter() Option

WithDefaultEndpointExporter initializes the Provider with an exporter using a default endpoint.

func WithDeployAttribute added in v0.0.33

func WithDeployAttribute(deploy string) Option

WithDeployAttribute adds the "deploy" attribute.

func WithEndpointExporter

func WithEndpointExporter(endpoint string) Option

WithEndpointExporter initializes the Provider with a default exporter.

func WithExporter

func WithExporter(exp exporter) Option

WithExporter initializes the Provider with an exporter.

func WithServiceInstanceIDAttribute added in v0.0.33

func WithServiceInstanceIDAttribute(serviceInstanceID string) Option

WithServiceInstanceIDAttribute adds the "service.instance.id" attribute.

func WithStageAttribute added in v0.0.33

func WithStageAttribute(stage string) Option

WithStageAttribute adds the "stage" and "_subservice" attributes.

type Provider

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

Provider initializes a global otlp meter provider that can collect metrics and use a collector to push those metrics to various backends (e.g. Argus, Honeycomb). Initialize with New(...). An initialized Provider must be started before it can be used to provide a Meter (i.e. p.Start()).

func (*Provider) Meter

func (p *Provider) Meter(name string) metric.Meter

Meter returns an oltp meter used for the creation of metric instruments. This relies on the Provider's controller having been properly initialized.

func (*Provider) NewCardinalityCounter

func (p *Provider) NewCardinalityCounter(name string) xmetrics.CardinalityCounter

NewCardinalityCounter implements metrics.Provider.

func (*Provider) NewCounter

func (p *Provider) NewCounter(name string) metrics.Counter

NewCounter creates a new Counter.

func (*Provider) NewGauge

func (p *Provider) NewGauge(name string) metrics.Gauge

NewGauge implements metrics.Provider.

func (*Provider) NewHistogram

func (p *Provider) NewHistogram(name string, buckets int) metrics.Histogram

NewHistogram implements metrics.Provider.

func (*Provider) Start

func (p *Provider) Start() error

Start starts the provider's controller and exporter.

func (*Provider) Stop

func (p *Provider) Stop()

Stop shuts down the provider's controller and exporter. It should be used to ensure the metrics provider drains all metrics before exiting the program.

Jump to

Keyboard shortcuts

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