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 Cloud(val string) attribute.KeyValue
- func Component(name string) attribute.KeyValue
- func CumulativeTemporalitySelector(_ metric.InstrumentKind) metricdata.Temporality
- func DefaultTemporalitySelector(ik metric.InstrumentKind) metricdata.Temporality
- func DeltaTemporalitySelector(_ metric.InstrumentKind) metricdata.Temporality
- func EnvironmentConv(stage string) []attribute.KeyValue
- func ExponentialAggregationSelector(ik metric.InstrumentKind) metric.Aggregation
- func HoneycombDataset(val string) attribute.KeyValue
- func MetricsDestinations(destinations []string) []attribute.KeyValue
- func New(ctx context.Context, serviceName string, opts ...Option) (xmetrics.Provider, error)
- func SemConv(name, namespace, instanceID string) []attribute.KeyValue
- func Service(name string) attribute.KeyValue
- func ServiceConv(name string) []attribute.KeyValue
- func Stage(val string) attribute.KeyValue
- func SubService(val string) attribute.KeyValue
- type Counter
- type Gauge
- type Histogram
- type Option
- func WithAggregationSelector(selector metric.AggregationSelector) Option
- func WithAttributes(attributes ...attribute.KeyValue) Option
- func WithCollectPeriod(collectPeriod time.Duration) Option
- func WithCumulativeTemporality() Option
- func WithDefaultTemporality() Option
- func WithDeltaTemporality() Option
- func WithEnvironmentStandard(env string) Option
- func WithExplicitAggregation() Option
- func WithExplicitHistograms() Optiondeprecated
- func WithExponentialAggregation() Option
- func WithExponentialHistograms() Optiondeprecated
- func WithExporterFunc(fn exporterFactory) Option
- func WithGRPCExporter(endpoint string, options ...otlpmetricgrpc.Option) Option
- func WithHTTPEndpointExporter(endpoint string, options ...otlpmetrichttp.Option) Option
- func WithHTTPExporter(options ...otlpmetrichttp.Option) Option
- func WithOpenTelemetryStandardService(name, namespace, instanceID string) Option
- func WithPrefix(prefix string) Option
- func WithResource(res *resource.Resource) Option
- func WithRuntimeInstrumentation(b bool) Option
- func WithServiceStandard(name string) Option
- func WithTemporalitySelector(temporality metric.TemporalitySelector) Option
- type Provider
- func (p *Provider) Flush() error
- func (p *Provider) NewCardinalityCounter(name string) xmetrics.CardinalityCounter
- func (p *Provider) NewCounter(name string) metrics.Counter
- func (p *Provider) NewExplicitHistogram(name string, fn xmetrics.DistributionFunc) metrics.Histogram
- 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 ( // ServiceKey is the attribute key for the `_service` convention. ServiceKey = attribute.Key("_service") // ComponentKey is the attribute key for the `component` convention ComponentKey = attribute.Key("component") )
Service level resource attributes
const ( // StageKey is the attribute key for the `stage` convention. StageKey = attribute.Key("stage") // SubServiceKey is the attribute key for the `_subservice` convention. SubServiceKey = attribute.Key("_subservice") // CloudKey is the attribute key for the `cloud` convention. CloudKey = attribute.Key("cloud") )
Environment level resource attributes
const ( // HoneycombDatasetKey maps to the honeycomb specific dataset attribute HoneycombDatasetKey = attribute.Key("dataset") MetricDestinationVal = "true" )
const (
// DefaultAgentEndpoint is a default exporter endpoint that points to a local otel collector.
DefaultAgentEndpoint = "http://0.0.0.0:55680"
)
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") )
var ( DefaultAggregationSelector = WithExponentialHistograms DefaultEndpointExporter = WithHTTPExporter )
var DefaultReaderInterval = time.Minute
var ExplicitAggregationSelector = metric.DefaultAggregationSelector
Functions ¶
func Component ¶ added in v0.1.0
Component returns an attribute.KeyValue for the `component` attribute.
func CumulativeTemporalitySelector ¶ added in v0.1.0
func CumulativeTemporalitySelector(_ metric.InstrumentKind) metricdata.Temporality
func DefaultTemporalitySelector ¶ added in v0.2.3
func DefaultTemporalitySelector(ik metric.InstrumentKind) metricdata.Temporality
DefaultTemporalitySelector uses delta temporality for all instrument kinds, except UpDown counters it uses cumulative temporality.
func DeltaTemporalitySelector ¶ added in v0.1.0
func DeltaTemporalitySelector(_ metric.InstrumentKind) metricdata.Temporality
func EnvironmentConv ¶ added in v0.1.0
EnvironmentConv returns an attribute list for the `stage` and `_subservice` convention.
func ExponentialAggregationSelector ¶ added in v0.1.0
func ExponentialAggregationSelector(ik metric.InstrumentKind) metric.Aggregation
func HoneycombDataset ¶ added in v0.1.0
HoneycombDataset sets the value for the honeycomb `dataset` attribute.
func MetricsDestinations ¶ added in v0.1.0
MetricsDestinations appends attributes for each destination in the provided list.
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 SemConv ¶ added in v0.1.0
SemConv returns a list of semconv attribute tags for `service.name`, `service.namespace` and `service.instance.id`.
func ServiceConv ¶ added in v0.1.0
ServiceConv returns an attriubte list for the `_service` and `component` convention.
func SubService ¶ added in v0.1.0
SubService returns an attribute.KeyValue for the `_subservice` attribute.
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 ¶
type Option func(*config) error
Option is used for optional arguments when initializing Provider.
func WithAggregationSelector ¶ added in v0.1.0
func WithAggregationSelector(selector metric.AggregationSelector) Option
func WithAttributes ¶
WithAttributes initializes a serviceNameResource with attributes. This is a deprecated function provided for convenence.
func WithCollectPeriod ¶ added in v0.0.47
WithCollectPeriod initial
func WithCumulativeTemporality ¶ added in v0.1.0
func WithCumulativeTemporality() Option
func WithDefaultTemporality ¶ added in v0.2.3
func WithDefaultTemporality() Option
func WithDeltaTemporality ¶ added in v0.1.0
func WithDeltaTemporality() Option
func WithEnvironmentStandard ¶ added in v0.1.0
WithEnvironmentStandard returns an Option that configures service attributes for the EnvironmentConv convention.
func WithExplicitAggregation ¶ added in v0.1.0
func WithExplicitAggregation() Option
func WithExplicitHistograms
deprecated
added in
v0.1.0
func WithExplicitHistograms() Option
Deprecated: WithExplicitHistograms is deprecated use WithExplicitAggregation instead.
func WithExponentialAggregation ¶ added in v0.1.0
func WithExponentialAggregation() Option
func WithExponentialHistograms
deprecated
added in
v0.1.0
func WithExponentialHistograms() Option
Deprecated: WithExponentialHistograms is deprecated use WithExponentialAggregation instead.
func WithExporterFunc ¶ added in v0.1.0
func WithExporterFunc(fn exporterFactory) Option
func WithGRPCExporter ¶ added in v0.1.0
func WithGRPCExporter(endpoint string, options ...otlpmetricgrpc.Option) Option
func WithHTTPEndpointExporter ¶ added in v0.1.0
func WithHTTPEndpointExporter(endpoint string, options ...otlpmetrichttp.Option) Option
func WithHTTPExporter ¶ added in v0.1.0
func WithHTTPExporter(options ...otlpmetrichttp.Option) Option
func WithOpenTelemetryStandardService ¶ added in v0.1.0
WithOpenTelemetryStandardService returns an Option that configures service attributes according to open-telemetry semconv conventions.
func WithPrefix ¶ added in v0.1.0
func WithResource ¶ added in v0.1.0
WithResource will merge the given resource with the provided default, any duplicate attributes will be overwritten.
func WithRuntimeInstrumentation ¶ added in v0.2.3
func WithServiceStandard ¶ added in v0.1.0
WithServiceStandard returns an Option that configures service attributes for the ServiceConv convention.
func WithTemporalitySelector ¶ added in v0.1.0
func WithTemporalitySelector(temporality metric.TemporalitySelector) Option
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) NewCardinalityCounter ¶
func (p *Provider) NewCardinalityCounter(name string) xmetrics.CardinalityCounter
NewCardinalityCounter implements metrics.Provider.
func (*Provider) NewCounter ¶
NewCounter creates a new Counter.
func (*Provider) NewExplicitHistogram ¶ added in v0.0.48
func (*Provider) NewHistogram ¶
NewHistogram implements metrics.Provider.