Skip to content

Commit

Permalink
Convert XConfigure into constructor for metrics (#1175)
Browse files Browse the repository at this point in the history
* Convert XConfigure into constructor for metrics

A follow up of #1155.

* Add to CHANGELOG

Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
rakyll and MrAlias authored Sep 15, 2020
1 parent 3de7a07 commit 2621bd4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion api/global/internal/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion api/metric/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
12 changes: 6 additions & 6 deletions api/metric/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/metric/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...),
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/metric/sdkapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

0 comments on commit 2621bd4

Please sign in to comment.