diff --git a/CHANGELOG.md b/CHANGELOG.md index fcac7fe019af..53e71f386ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm recommend the use of `newConfig()` instead of `configure()`. (#1163) - The `otlp.Config` type has been unexported and changed to `otlp.config`, along with its initializer. (#1163) - Don't consider unset environment variable for resource detection to be an error. (#1170) +- Rename `go.opentelemetry.io/otel/api/metric.ConfigureInstrument` to `NewInstrumentConfig` and + `go.opentelemetry.io/otel/api/metric.ConfigureMeter` to `NewMeterConfig`. ### Fixed diff --git a/api/global/internal/meter.go b/api/global/internal/meter.go index ce3ed20996cf..3c7764f72682 100644 --- a/api/global/internal/meter.go +++ b/api/global/internal/meter.go @@ -152,7 +152,7 @@ func (p *meterProvider) Meter(instrumentationName string, opts ...metric.MeterOp key := meterKey{ Name: instrumentationName, - Version: metric.ConfigureMeter(opts).InstrumentationVersion, + Version: metric.NewMeterConfig(opts...).InstrumentationVersion, } entry, ok := p.meters[key] if !ok { diff --git a/api/metric/api_test.go b/api/metric/api_test.go index b74d7865cd22..777f8efeb1be 100644 --- a/api/metric/api_test.go +++ b/api/metric/api_test.go @@ -110,7 +110,7 @@ func TestOptions(t *testing.T) { } for idx, tt := range testcases { t.Logf("Testing counter case %s (%d)", tt.name, idx) - if diff := cmp.Diff(metric.ConfigureInstrument(tt.opts), metric.InstrumentConfig{ + if diff := cmp.Diff(metric.NewInstrumentConfig(tt.opts...), metric.InstrumentConfig{ Description: tt.desc, Unit: tt.unit, }); diff != "" { diff --git a/api/metric/config.go b/api/metric/config.go index b5d45f9aeb9c..e937f467f870 100644 --- a/api/metric/config.go +++ b/api/metric/config.go @@ -37,9 +37,9 @@ type InstrumentOption interface { ApplyInstrument(*InstrumentConfig) } -// ConfigureInstrument is a helper that applies all the InstrumentOptions -// to an InstrumentConfig. -func ConfigureInstrument(opts []InstrumentOption) InstrumentConfig { +// NewInstrumentConfig creates a new InstrumentConfig +// and applies all the given options. +func NewInstrumentConfig(opts ...InstrumentOption) InstrumentConfig { var config InstrumentConfig for _, o := range opts { o.ApplyInstrument(&config) @@ -93,9 +93,9 @@ type MeterOption interface { ApplyMeter(*MeterConfig) } -// ConfigureMeter is a helper that applies all the MeterOptions to a -// MeterConfig. -func ConfigureMeter(opts []MeterOption) MeterConfig { +// NewMeterConfig creates a new MeterConfig and applies +// all the given options. +func NewMeterConfig(opts ...MeterOption) MeterConfig { var config MeterConfig for _, o := range opts { o.ApplyMeter(&config) diff --git a/api/metric/descriptor.go b/api/metric/descriptor.go index ccc2e94b5c6f..512c65bcbb38 100644 --- a/api/metric/descriptor.go +++ b/api/metric/descriptor.go @@ -32,7 +32,7 @@ func NewDescriptor(name string, mkind Kind, nkind NumberKind, opts ...Instrument name: name, kind: mkind, numberKind: nkind, - config: ConfigureInstrument(opts), + config: NewInstrumentConfig(opts...), } } diff --git a/api/metric/sdkapi.go b/api/metric/sdkapi.go index 3c4e11ee4fb6..20c3905606e3 100644 --- a/api/metric/sdkapi.go +++ b/api/metric/sdkapi.go @@ -89,6 +89,6 @@ func WrapMeterImpl(impl MeterImpl, instrumentatioName string, opts ...MeterOptio return Meter{ impl: impl, name: instrumentatioName, - version: ConfigureMeter(opts).InstrumentationVersion, + version: NewMeterConfig(opts...).InstrumentationVersion, } }