mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-12 02:28:07 +02:00
90df52586b
* Split metric configuration down to instrument * Rename *ObserverOptions to *ObservableOption * Update option docs with links
169 lines
4.7 KiB
Go
169 lines
4.7 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
|
|
|
// Observable is used as a grouping mechanism for all instruments that are
|
|
// updated within a Callback.
|
|
type Observable interface {
|
|
observable()
|
|
}
|
|
|
|
// Option applies options to all instruments.
|
|
type Option interface {
|
|
Int64CounterOption
|
|
Int64UpDownCounterOption
|
|
Int64HistogramOption
|
|
Int64ObservableCounterOption
|
|
Int64ObservableUpDownCounterOption
|
|
Int64ObservableGaugeOption
|
|
|
|
Float64CounterOption
|
|
Float64UpDownCounterOption
|
|
Float64HistogramOption
|
|
Float64ObservableCounterOption
|
|
Float64ObservableUpDownCounterOption
|
|
Float64ObservableGaugeOption
|
|
}
|
|
|
|
type descOpt string
|
|
|
|
func (o descOpt) applyFloat64Counter(c Float64CounterConfig) Float64CounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyFloat64UpDownCounter(c Float64UpDownCounterConfig) Float64UpDownCounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyFloat64Histogram(c Float64HistogramConfig) Float64HistogramConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyFloat64ObservableGauge(c Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyInt64Counter(c Int64CounterConfig) Int64CounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyInt64UpDownCounter(c Int64UpDownCounterConfig) Int64UpDownCounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyInt64Histogram(c Int64HistogramConfig) Int64HistogramConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o descOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
|
c.description = string(o)
|
|
return c
|
|
}
|
|
|
|
// WithDescription sets the instrument description.
|
|
func WithDescription(desc string) Option { return descOpt(desc) }
|
|
|
|
type unitOpt string
|
|
|
|
func (o unitOpt) applyFloat64Counter(c Float64CounterConfig) Float64CounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyFloat64UpDownCounter(c Float64UpDownCounterConfig) Float64UpDownCounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyFloat64Histogram(c Float64HistogramConfig) Float64HistogramConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyFloat64ObservableGauge(c Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyInt64Counter(c Int64CounterConfig) Int64CounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyInt64UpDownCounter(c Int64UpDownCounterConfig) Int64UpDownCounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyInt64Histogram(c Int64HistogramConfig) Int64HistogramConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
func (o unitOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
|
c.unit = string(o)
|
|
return c
|
|
}
|
|
|
|
// WithUnit sets the instrument unit.
|
|
func WithUnit(u string) Option { return unitOpt(u) }
|