Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split metric configuration down to instrument #3895

Merged
merged 9 commits into from
Mar 21, 2023
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The `WithoutTimestamps` option to `go.opentelemetry.io/otel/exporters/stdout/stdoutmetric` to sets all timestamps to zero. (#3828)
- The new `Exemplar` type is added to `go.opentelemetry.io/otel/sdk/metric/metricdata`.
Both the `DataPoint` and `HistogramDataPoint` types from that package have a new field of `Exemplars` containing the sampled exemplars for their timeseries. (#3849)
- Configuration for each metric instrument in `go.opentelemetry.io/otel/sdk/metric/instrument`. (#3895)

### Changed

Expand All @@ -23,11 +24,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Both the `Histogram` and `HistogramDataPoint` are redefined with a generic argument of `[N int64 | float64]` in `go.opentelemetry.io/otel/sdk/metric/metricdata`. (#3849)
- The metric `Export` interface from `go.opentelemetry.io/otel/sdk/metric` accepts a `*ResourceMetrics` instead of `ResourceMetrics`. (#3853)
- Rename `Asynchronous` to `Observable` in `go.opentelemetry.io/otel/metric/instrument`. (#3892)
- Rename `Int64ObserverOption` to `Int64ObservableOption` in `go.opentelemetry.io/otel/metric/instrument`. (#3895)
- Rename `Float64ObserverOption` to `Float64ObservableOption` in `go.opentelemetry.io/otel/metric/instrument`. (#3895)

### Removed

- The deprecated `go.opentelemetry.io/otel/metric/global` package is removed. (#3829)
- The unneeded `Synchronous` interface in `go.opentelemetry.io/otel/metric/instrument` was removed. (#3892)
- The `Float64ObserverConfig` and `NewFloat64ObserverConfig` in `go.opentelemetry.io/otel/sdk/metric/instrument`.
Use the added `float64` instrument configuration instead. (#3895)
- The `Int64ObserverConfig` and `NewInt64ObserverConfig` in `go.opentelemetry.io/otel/sdk/metric/instrument`.
Use the added `int64` instrument configuration instead. (#3895)

## [1.15.0-rc.1/0.38.0-rc.1] 2023-03-01

Expand Down
24 changes: 12 additions & 12 deletions internal/global/instruments.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type afCounter struct {
instrument.Float64Observable

name string
opts []instrument.Float64ObserverOption
opts []instrument.Float64ObservableCounterOption

delegate atomic.Value //instrument.Float64ObservableCounter
}
Expand Down Expand Up @@ -60,7 +60,7 @@ type afUpDownCounter struct {
instrument.Float64Observable

name string
opts []instrument.Float64ObserverOption
opts []instrument.Float64ObservableUpDownCounterOption

delegate atomic.Value //instrument.Float64ObservableUpDownCounter
}
Expand Down Expand Up @@ -88,7 +88,7 @@ type afGauge struct {
instrument.Float64Observable

name string
opts []instrument.Float64ObserverOption
opts []instrument.Float64ObservableGaugeOption

delegate atomic.Value //instrument.Float64ObservableGauge
}
Expand Down Expand Up @@ -116,7 +116,7 @@ type aiCounter struct {
instrument.Int64Observable

name string
opts []instrument.Int64ObserverOption
opts []instrument.Int64ObservableCounterOption

delegate atomic.Value //instrument.Int64ObservableCounter
}
Expand Down Expand Up @@ -144,7 +144,7 @@ type aiUpDownCounter struct {
instrument.Int64Observable

name string
opts []instrument.Int64ObserverOption
opts []instrument.Int64ObservableUpDownCounterOption

delegate atomic.Value //instrument.Int64ObservableUpDownCounter
}
Expand Down Expand Up @@ -172,7 +172,7 @@ type aiGauge struct {
instrument.Int64Observable

name string
opts []instrument.Int64ObserverOption
opts []instrument.Int64ObservableGaugeOption

delegate atomic.Value //instrument.Int64ObservableGauge
}
Expand All @@ -199,7 +199,7 @@ func (i *aiGauge) Unwrap() instrument.Observable {
// Sync Instruments.
type sfCounter struct {
name string
opts []instrument.Float64Option
opts []instrument.Float64CounterOption

delegate atomic.Value //instrument.Float64Counter
}
Expand All @@ -223,7 +223,7 @@ func (i *sfCounter) Add(ctx context.Context, incr float64, attrs ...attribute.Ke

type sfUpDownCounter struct {
name string
opts []instrument.Float64Option
opts []instrument.Float64UpDownCounterOption

delegate atomic.Value //instrument.Float64UpDownCounter
}
Expand All @@ -247,7 +247,7 @@ func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, attrs ...attrib

type sfHistogram struct {
name string
opts []instrument.Float64Option
opts []instrument.Float64HistogramOption

delegate atomic.Value //instrument.Float64Histogram
}
Expand All @@ -271,7 +271,7 @@ func (i *sfHistogram) Record(ctx context.Context, x float64, attrs ...attribute.

type siCounter struct {
name string
opts []instrument.Int64Option
opts []instrument.Int64CounterOption

delegate atomic.Value //instrument.Int64Counter
}
Expand All @@ -295,7 +295,7 @@ func (i *siCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValu

type siUpDownCounter struct {
name string
opts []instrument.Int64Option
opts []instrument.Int64UpDownCounterOption

delegate atomic.Value //instrument.Int64UpDownCounter
}
Expand All @@ -319,7 +319,7 @@ func (i *siUpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.K

type siHistogram struct {
name string
opts []instrument.Int64Option
opts []instrument.Int64HistogramOption

delegate atomic.Value //instrument.Int64Histogram
}
Expand Down
24 changes: 12 additions & 12 deletions internal/global/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (m *meter) setDelegate(provider metric.MeterProvider) {
m.registry.Init()
}

func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) {
func (m *meter) Int64Counter(name string, options ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64Counter(name, options...)
}
Expand All @@ -147,7 +147,7 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (in
return i, nil
}

func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64UpDownCounter(name, options...)
}
Expand All @@ -158,7 +158,7 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Optio
return i, nil
}

func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) {
func (m *meter) Int64Histogram(name string, options ...instrument.Int64HistogramOption) (instrument.Int64Histogram, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64Histogram(name, options...)
}
Expand All @@ -169,7 +169,7 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (
return i, nil
}

func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) {
func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64ObservableCounter(name, options...)
}
Expand All @@ -180,7 +180,7 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O
return i, nil
}

func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) {
func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64ObservableUpDownCounter(name, options...)
}
Expand All @@ -191,7 +191,7 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.
return i, nil
}

func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) {
func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Int64ObservableGauge(name, options...)
}
Expand All @@ -202,7 +202,7 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs
return i, nil
}

func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) {
func (m *meter) Float64Counter(name string, options ...instrument.Float64CounterOption) (instrument.Float64Counter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64Counter(name, options...)
}
Expand All @@ -213,7 +213,7 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Option)
return i, nil
}

func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) {
func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64UpDownCounter(name, options...)
}
Expand All @@ -224,7 +224,7 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64O
return i, nil
}

func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) {
func (m *meter) Float64Histogram(name string, options ...instrument.Float64HistogramOption) (instrument.Float64Histogram, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64Histogram(name, options...)
}
Expand All @@ -235,7 +235,7 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Optio
return i, nil
}

func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) {
func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64ObservableCounter(name, options...)
}
Expand All @@ -246,7 +246,7 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa
return i, nil
}

func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) {
func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64ObservableUpDownCounter(name, options...)
}
Expand All @@ -257,7 +257,7 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen
return i, nil
}

func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) {
func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error) {
if del, ok := m.delegate.Load().(metric.Meter); ok {
return del.Float64ObservableGauge(name, options...)
}
Expand Down
24 changes: 12 additions & 12 deletions internal/global/meter_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,62 +52,62 @@ type testMeter struct {
callbacks []metric.Callback
}

func (m *testMeter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) {
func (m *testMeter) Int64Counter(name string, options ...instrument.Int64CounterOption) (instrument.Int64Counter, error) {
m.siCount++
return &testCountingIntInstrument{}, nil
}

func (m *testMeter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
func (m *testMeter) Int64UpDownCounter(name string, options ...instrument.Int64UpDownCounterOption) (instrument.Int64UpDownCounter, error) {
m.siUDCount++
return &testCountingIntInstrument{}, nil
}

func (m *testMeter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) {
func (m *testMeter) Int64Histogram(name string, options ...instrument.Int64HistogramOption) (instrument.Int64Histogram, error) {
m.siHist++
return &testCountingIntInstrument{}, nil
}

func (m *testMeter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) {
func (m *testMeter) Int64ObservableCounter(name string, options ...instrument.Int64ObservableCounterOption) (instrument.Int64ObservableCounter, error) {
m.aiCount++
return &testCountingIntInstrument{}, nil
}

func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) {
func (m *testMeter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObservableUpDownCounterOption) (instrument.Int64ObservableUpDownCounter, error) {
m.aiUDCount++
return &testCountingIntInstrument{}, nil
}

func (m *testMeter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) {
func (m *testMeter) Int64ObservableGauge(name string, options ...instrument.Int64ObservableGaugeOption) (instrument.Int64ObservableGauge, error) {
m.aiGauge++
return &testCountingIntInstrument{}, nil
}

func (m *testMeter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) {
func (m *testMeter) Float64Counter(name string, options ...instrument.Float64CounterOption) (instrument.Float64Counter, error) {
m.sfCount++
return &testCountingFloatInstrument{}, nil
}

func (m *testMeter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) {
func (m *testMeter) Float64UpDownCounter(name string, options ...instrument.Float64UpDownCounterOption) (instrument.Float64UpDownCounter, error) {
m.sfUDCount++
return &testCountingFloatInstrument{}, nil
}

func (m *testMeter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) {
func (m *testMeter) Float64Histogram(name string, options ...instrument.Float64HistogramOption) (instrument.Float64Histogram, error) {
m.sfHist++
return &testCountingFloatInstrument{}, nil
}

func (m *testMeter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) {
func (m *testMeter) Float64ObservableCounter(name string, options ...instrument.Float64ObservableCounterOption) (instrument.Float64ObservableCounter, error) {
m.afCount++
return &testCountingFloatInstrument{}, nil
}

func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) {
func (m *testMeter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObservableUpDownCounterOption) (instrument.Float64ObservableUpDownCounter, error) {
m.afUDCount++
return &testCountingFloatInstrument{}, nil
}

func (m *testMeter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) {
func (m *testMeter) Float64ObservableGauge(name string, options ...instrument.Float64ObservableGaugeOption) (instrument.Float64ObservableGauge, error) {
m.afGauge++
return &testCountingFloatInstrument{}, nil
}
Expand Down
Loading