Convert XConfigure into constructor for metrics (#1175)
* Convert XConfigure into constructor for metrics A follow up of #1155. * Add to CHANGELOG Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
3de7a07089
commit
2621bd4847
|
@ -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)
|
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)
|
- 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)
|
- 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
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ func (p *meterProvider) Meter(instrumentationName string, opts ...metric.MeterOp
|
||||||
|
|
||||||
key := meterKey{
|
key := meterKey{
|
||||||
Name: instrumentationName,
|
Name: instrumentationName,
|
||||||
Version: metric.ConfigureMeter(opts).InstrumentationVersion,
|
Version: metric.NewMeterConfig(opts...).InstrumentationVersion,
|
||||||
}
|
}
|
||||||
entry, ok := p.meters[key]
|
entry, ok := p.meters[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -110,7 +110,7 @@ func TestOptions(t *testing.T) {
|
||||||
}
|
}
|
||||||
for idx, tt := range testcases {
|
for idx, tt := range testcases {
|
||||||
t.Logf("Testing counter case %s (%d)", tt.name, idx)
|
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,
|
Description: tt.desc,
|
||||||
Unit: tt.unit,
|
Unit: tt.unit,
|
||||||
}); diff != "" {
|
}); diff != "" {
|
||||||
|
|
|
@ -37,9 +37,9 @@ type InstrumentOption interface {
|
||||||
ApplyInstrument(*InstrumentConfig)
|
ApplyInstrument(*InstrumentConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigureInstrument is a helper that applies all the InstrumentOptions
|
// NewInstrumentConfig creates a new InstrumentConfig
|
||||||
// to an InstrumentConfig.
|
// and applies all the given options.
|
||||||
func ConfigureInstrument(opts []InstrumentOption) InstrumentConfig {
|
func NewInstrumentConfig(opts ...InstrumentOption) InstrumentConfig {
|
||||||
var config InstrumentConfig
|
var config InstrumentConfig
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o.ApplyInstrument(&config)
|
o.ApplyInstrument(&config)
|
||||||
|
@ -93,9 +93,9 @@ type MeterOption interface {
|
||||||
ApplyMeter(*MeterConfig)
|
ApplyMeter(*MeterConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigureMeter is a helper that applies all the MeterOptions to a
|
// NewMeterConfig creates a new MeterConfig and applies
|
||||||
// MeterConfig.
|
// all the given options.
|
||||||
func ConfigureMeter(opts []MeterOption) MeterConfig {
|
func NewMeterConfig(opts ...MeterOption) MeterConfig {
|
||||||
var config MeterConfig
|
var config MeterConfig
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o.ApplyMeter(&config)
|
o.ApplyMeter(&config)
|
||||||
|
|
|
@ -32,7 +32,7 @@ func NewDescriptor(name string, mkind Kind, nkind NumberKind, opts ...Instrument
|
||||||
name: name,
|
name: name,
|
||||||
kind: mkind,
|
kind: mkind,
|
||||||
numberKind: nkind,
|
numberKind: nkind,
|
||||||
config: ConfigureInstrument(opts),
|
config: NewInstrumentConfig(opts...),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,6 @@ func WrapMeterImpl(impl MeterImpl, instrumentatioName string, opts ...MeterOptio
|
||||||
return Meter{
|
return Meter{
|
||||||
impl: impl,
|
impl: impl,
|
||||||
name: instrumentatioName,
|
name: instrumentatioName,
|
||||||
version: ConfigureMeter(opts).InstrumentationVersion,
|
version: NewMeterConfig(opts...).InstrumentationVersion,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue