Skip to content

Commit

Permalink
Fix removal changes from open-telemetry#3154 in API
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Sep 15, 2022
1 parent 398f087 commit e0e1db2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 166 deletions.
18 changes: 0 additions & 18 deletions metric/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@

package metric // import "go.opentelemetry.io/otel/metric"

import "go.opentelemetry.io/otel/attribute"

// MeterConfig contains options for Meters.
type MeterConfig struct {
instrumentationVersion string
schemaURL string
attributes attribute.Set
}

// InstrumentationVersion is the version of the library providing instrumentation.
Expand All @@ -33,11 +30,6 @@ func (cfg MeterConfig) SchemaURL() string {
return cfg.schemaURL
}

// Attributes returns the scope attribute set of the Meter.
func (t MeterConfig) Attributes() attribute.Set {
return t.attributes
}

// MeterOption is an interface for applying Meter options.
type MeterOption interface {
// applyMeter is used to set a MeterOption value of a MeterConfig.
Expand Down Expand Up @@ -75,13 +67,3 @@ func WithSchemaURL(schemaURL string) MeterOption {
return config
})
}

// WithScopeAttributes sets the attributes for the scope of a Meter. The
// attributes are stored as an attribute set. Duplicate values are removed, the
// last value is used.
func WithScopeAttributes(attr ...attribute.KeyValue) MeterOption {
return meterOptionFunc(func(cfg MeterConfig) MeterConfig {
cfg.attributes = attribute.NewSet(attr...)
return cfg
})
}
69 changes: 0 additions & 69 deletions metric/config_test.go

This file was deleted.

51 changes: 8 additions & 43 deletions metric/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,15 @@ import (
"go.opentelemetry.io/otel/metric/instrument/syncint64"
)

// MeterProvider provides Meters that are used by instrumentation code to
// create instruments that measure code operations.
//
// A MeterProvider is the collection destination of all measurements made from
// instruments the provided Meters created, it represents a unique telemetry
// collection pipeline. How that pipeline is defined, meaning how those
// measurements are collected, processed, and where they are exported, depends
// on its implementation. Instrumentation authors do not need to define this
// implementation, rather just use the provided Meters to instrument code.
//
// Commonly, instrumentation code will accept a MeterProvider implementation at
// runtime from its users or it can simply use the globally registered one (see
// https://pkg.go.dev/go.opentelemetry.io/otel/metric/global#MeterProvider).
//
// Warning: methods may be added to this interface in minor releases.
// MeterProvider provides access to named Meter instances, for instrumenting
// an application or library.
type MeterProvider interface {
// Meter returns a unique Meter scoped to be used by instrumentation code
// to measure code operations. The scope and identity of that
// instrumentation code is uniquely defined by the name and options passed.
//
// The passed name needs to uniquely identify instrumentation code.
// Therefore, it is recommended that name is the Go package name of the
// library providing instrumentation (note: not the code being
// instrumented). Instrumentation libraries can have multiple versions,
// therefore, the WithInstrumentationVersion option should be used to
// distinguish these different codebases. Additionally, instrumentation
// libraries may sometimes use metric measurements to communicate different
// domains of code operations data (i.e. using different Meters to
// communicate user experience and back-end operations). If this is the
// case, the WithScopeAttributes option should be used to uniquely identify
// Meters that handle the different domains of code operations data.
//
// If the same name and options are passed multiple times, the same Meter
// will be returned (it is up to the implementation if this will be the
// same underlying instance of that Meter or not). It is not necessary to
// call this multiple times with the same name and options to get an
// up-to-date Meter. All implementations will ensure any MeterProvider
// configuration changes are propagated to all provided Meters.
//
// If name is empty, then an implementation defined default name will be
// used instead.
//
// This method is safe to call concurrently.
Meter(name string, options ...MeterOption) Meter
// Meter creates an instance of a `Meter` interface. The instrumentationName
// must be the name of the library providing instrumentation. This name may
// be the same as the instrumented code only if that code provides built-in
// instrumentation. If the instrumentationName is empty, then a
// implementation defined default name will be used instead.
Meter(instrumentationName string, opts ...MeterOption) Meter
}

// Meter provides access to instrument instances for recording metrics.
Expand Down
18 changes: 1 addition & 17 deletions trace/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import (
type TracerConfig struct {
instrumentationVersion string
// Schema URL of the telemetry emitted by the Tracer.
schemaURL string
attributes attribute.Set
schemaURL string
}

// InstrumentationVersion returns the version of the library providing instrumentation.
Expand All @@ -38,11 +37,6 @@ func (t *TracerConfig) SchemaURL() string {
return t.schemaURL
}

// Attributes returns the scope attribute set of the Tracer.
func (t *TracerConfig) Attributes() attribute.Set {
return t.attributes
}

// NewTracerConfig applies all the options to a returned TracerConfig.
func NewTracerConfig(options ...TracerOption) TracerConfig {
var config TracerConfig
Expand Down Expand Up @@ -320,13 +314,3 @@ func WithSchemaURL(schemaURL string) TracerOption {
return cfg
})
}

// WithScopeAttributes sets the attributes for the scope of a Tracer. The
// attributes are stored as an attribute set. Duplicate values are removed, the
// last value is used.
func WithScopeAttributes(attr ...attribute.KeyValue) TracerOption {
return tracerOptionFunc(func(cfg TracerConfig) TracerConfig {
cfg.attributes = attribute.NewSet(attr...)
return cfg
})
}
19 changes: 0 additions & 19 deletions trace/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ func TestTracerConfig(t *testing.T) {
v1 := "semver:0.0.1"
v2 := "semver:1.0.0"
schemaURL := "https://opentelemetry.io/schemas/1.2.0"
one, two := attribute.Int("key", 1), attribute.Int("key", 2)
tests := []struct {
options []TracerOption
expected TracerConfig
Expand Down Expand Up @@ -247,24 +246,6 @@ func TestTracerConfig(t *testing.T) {
schemaURL: schemaURL,
},
},

{
[]TracerOption{
WithScopeAttributes(one, two),
},
TracerConfig{
attributes: attribute.NewSet(two),
},
},
{
[]TracerOption{
WithScopeAttributes(two),
WithScopeAttributes(one),
},
TracerConfig{
attributes: attribute.NewSet(one),
},
},
}
for _, test := range tests {
config := NewTracerConfig(test.options...)
Expand Down

0 comments on commit e0e1db2

Please sign in to comment.