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
- Variables
- func New(ctx context.Context, serviceName string, opts ...Option) (xmetrics.Provider, error)
- func NewHTTPClient(url *url.URL, opts ...otlpmetrichttp.Option) otlpmetric.Client
- type Counter
- type Gauge
- type Histogram
- type Option
- func WithAggregator(agg metric.AggregatorSelector) Option
- func WithAttributes(attributes ...attribute.KeyValue) Option
- func WithCloudAttribute(cloud string) Option
- func WithDefaultAggregator() Option
- func WithDefaultEndpointExporter() Option
- func WithEndpointExporter(endpoint string) Option
- func WithExporter(exp exporter) Option
- func WithServiceInstanceIDAttribute(serviceInstanceID string) Option
- func WithServiceNamespaceAttribute(serviceNamespace string) Option
- func WithStageAttribute(stage string) Option
- type Provider
- func (p *Provider) Flush() error
- func (p *Provider) Meter(name string) metric.Meter
- func (p *Provider) NewCardinalityCounter(name string) xmetrics.CardinalityCounter
- func (p *Provider) NewCounter(name string) metrics.Counter
- func (p *Provider) NewGauge(name string) metrics.Gauge
- func (p *Provider) NewHistogram(name string, buckets int) metrics.Histogram
- func (p *Provider) Start() error
- func (p *Provider) Stop()
Constants ¶
const DefaultAgentEndpoint = "0.0.0.0:55680"
DefaultAgentEndpoint is a default exporter endpoint that points to a local otel collector.
Variables ¶
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 ¶
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.
type Histogram ¶
type Histogram struct { metric.Float64Histogram // contains filtered or unexported fields }
Histogram is a histogram.
type Option ¶
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 ¶
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
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 WithEndpointExporter ¶
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
WithServiceInstanceIDAttribute adds the "service.instance.id" attribute.
func WithServiceNamespaceAttribute ¶ added in v0.0.38
WithServiceNamespaceAttribute adds the "service.namespace" attribute.
func WithStageAttribute ¶ added in v0.0.33
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) Flush ¶ added in v0.0.41
Flush stops and starts the controller in order to flush metrics immediately, without having to wait until the next collection occurs. The flush is synchronous and returns an error if the controller fails to flush or cannot restart after flushing.
func (*Provider) 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 ¶
NewCounter creates a new Counter.
func (*Provider) NewHistogram ¶
NewHistogram implements metrics.Provider.