mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-30 21:20:04 +02:00
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)
|
||||
- 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
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 != "" {
|
||||
|
@ -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)
|
||||
|
@ -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...),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user