Repository: open-telemetry/opentelemetry-go
Pull request #3154 (2022-09-08 18:54:22)

Revert Changes that add attributes to scope.
As was discussed in the spec meeting.  This change reverts the addition of attributes to scope, to not get ahead of the specification and unblock release of v1.10.

This will unblock #3145.  If these changes are added back, #3145 should block the v1.11 release.

Revert "Add instrumentation scope attributes (#3131)"

This reverts commit 0078faeb0e84d44dced8230b251b260fb2b912e5.

Revert "Add WithScopeAttributes MeterOption to metric API package (#3132)"

This reverts commit 81a9bab814231c386bfee8078a66f13bd457288d.

codecov[bot]: # [Codecov](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) Report
> Merging [#3154](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) (bc5eb79) into [main](https://codecov.io/gh/open-telemetry/opentelemetry-go/commit/13906ace5d600e6974a6eaf68b169c0583d246da?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) (13906ac) will **decrease** coverage by `0.1%`.
> The diff coverage is `100.0%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154/graphs/tree.svg?width=650&height=150&src=pr&token=8efTmh4kvf&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry)

```diff
@@           Coverage Diff           @@
##            main   #3154     +/-   ##
=======================================
- Coverage   76.4%   76.3%   -0.2%     
=======================================
  Files        180     180             
  Lines      12014   11992     -22     
=======================================
- Hits        9188    9155     -33     
- Misses      2585    2595     +10     
- Partials     241     242      +1     
```


| [Impacted Files](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry) | Coverage Δ | |
|---|---|---|
| [metric/config.go](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-bWV0cmljL2NvbmZpZy5nbw==) | `22.7% <ø> (-77.3%)` | :arrow_down: |
| [trace/config.go](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-dHJhY2UvY29uZmlnLmdv) | `64.1% <ø> (-0.5%)` | :arrow_down: |
| [...lptrace/internal/tracetransform/instrumentation.go](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-ZXhwb3J0ZXJzL290bHAvb3RscHRyYWNlL2ludGVybmFsL3RyYWNldHJhbnNmb3JtL2luc3RydW1lbnRhdGlvbi5nbw==) | `100.0% <100.0%> (ø)` | |
| [sdk/trace/provider.go](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-c2RrL3RyYWNlL3Byb3ZpZGVyLmdv) | `85.7% <100.0%> (-0.5%)` | :arrow_down: |
| [sdk/trace/batch\_span\_processor.go](https://codecov.io/gh/open-telemetry/opentelemetry-go/pull/3154/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=open-telemetry#diff-c2RrL3RyYWNlL2JhdGNoX3NwYW5fcHJvY2Vzc29yLmdv) | `81.9% <0.0%> (+1.7%)` | :arrow_up: |

</details>
MadVikingGod: I am merging this a bit early, to unblock the 1.10 release.  It has overwhelming approval, and was also discussed at the SIG.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4dec154c..c32557b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,9 +14,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
   Include compatibility testing and document support. (#3077)
 - Support the OTLP ExportTracePartialSuccess response; these are passed to the registered error handler. (#3106)
 - Upgrade go.opentelemetry.io/proto/otlp from v0.18.0 to v0.19.0 (#3107)
-- Add an `Attribute` field to the `Scope` type in `go.opentelemetry.io/otel/sdk/instrumentation`. (#3131)
-- Add the `WithScopeAttributes` `TracerOption` to the `go.opentelemetry.io/otel/trace` package. (#3131)
-- Add the `WithScopeAttributes` `MeterOption` to the `go.opentelemetry.io/otel/metric` package. (#3132)
 
 ### Changed
 
@@ -25,7 +22,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
   exact upper-inclusive boundary support following the [corresponding
   specification change](https://github.com/open-telemetry/opentelemetry-specification/pull/2633). (#2982)
 - Attempting to start a span with a nil `context` will no longer cause a panic. (#3110)
-- Export scope attributes for all exporters provided by `go.opentelemetry.io/otel/exporters/otlp/otlptrace`. (#3131)
 
 ## [1.9.0/0.0.3] - 2022-08-01
 
diff --git a/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go b/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go
index 4dcddb17..7aaec38d 100644
--- a/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go
+++ b/exporters/otlp/otlptrace/internal/tracetransform/instrumentation.go
@@ -24,8 +24,7 @@ func InstrumentationScope(il instrumentation.Scope) *commonpb.InstrumentationSco
 		return nil
 	}
 	return &commonpb.InstrumentationScope{
-		Name:       il.Name,
-		Version:    il.Version,
-		Attributes: Iterator(il.Attributes.Iter()),
+		Name:    il.Name,
+		Version: il.Version,
 	}
 }
diff --git a/metric/config.go b/metric/config.go
index ddadd62f..621e4c5f 100644
--- a/metric/config.go
+++ b/metric/config.go
@@ -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.
@@ -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.
@@ -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
-	})
-}
diff --git a/metric/meter.go b/metric/meter.go
index b5484053..21fc1c49 100644
--- a/metric/meter.go
+++ b/metric/meter.go
@@ -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.
diff --git a/sdk/instrumentation/scope.go b/sdk/instrumentation/scope.go
index 3001b6cc..09c6d93f 100644
--- a/sdk/instrumentation/scope.go
+++ b/sdk/instrumentation/scope.go
@@ -14,14 +14,7 @@
 
 package instrumentation // import "go.opentelemetry.io/otel/sdk/instrumentation"
 
-import "go.opentelemetry.io/otel/attribute"
-
-// Scope represents the instrumentation source of OpenTelemetry data.
-//
-// Code that uses OpenTelemetry APIs or data-models to produce telemetry needs
-// to be identifiable by the receiver of that data. A Scope is used for this
-// purpose, it uniquely identifies that code as the source and the extent to
-// which it is relevant.
+// Scope represents the instrumentation scope.
 type Scope struct {
 	// Name is the name of the instrumentation scope. This should be the
 	// Go package name of that scope.
@@ -30,13 +23,4 @@ type Scope struct {
 	Version string
 	// SchemaURL of the telemetry emitted by the scope.
 	SchemaURL string
-	// Attributes describe the unique attributes of an instrumentation scope.
-	//
-	// These attributes are used to differentiate an instrumentation scope when
-	// it emits data that belong to different domains. For example, if both
-	// profiling data and client-side data are emitted as log records from the
-	// same instrumentation library, they may need to be differentiated by a
-	// telemetry receiver. In that case, these attributes are used to scope and
-	// differentiate the data.
-	Attributes attribute.Set
 }
diff --git a/sdk/trace/provider.go b/sdk/trace/provider.go
index 74980179..292ea548 100644
--- a/sdk/trace/provider.go
+++ b/sdk/trace/provider.go
@@ -142,10 +142,9 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T
 		name = defaultTracerName
 	}
 	is := instrumentation.Scope{
-		Name:       name,
-		Version:    c.InstrumentationVersion(),
-		SchemaURL:  c.SchemaURL(),
-		Attributes: c.Attributes(),
+		Name:      name,
+		Version:   c.InstrumentationVersion(),
+		SchemaURL: c.SchemaURL(),
 	}
 	t, ok := p.namedTracer[is]
 	if !ok {
@@ -154,13 +153,7 @@ func (p *TracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.T
 			instrumentationScope: is,
 		}
 		p.namedTracer[is] = t
-		global.Info(
-			"Tracer created",
-			"name", name,
-			"version", c.InstrumentationVersion(),
-			"schemaURL", c.SchemaURL(),
-			"attributes", c.Attributes(),
-		)
+		global.Info("Tracer created", "name", name, "version", c.InstrumentationVersion(), "schemaURL", c.SchemaURL())
 	}
 	return t
 }
diff --git a/trace/config.go b/trace/config.go
index a7b7eab2..f058cc78 100644
--- a/trace/config.go
+++ b/trace/config.go
@@ -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.
@@ -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
@@ -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
-	})
-}


Test patch:
diff --git a/exporters/otlp/otlptrace/internal/tracetransform/instrumentation_test.go b/exporters/otlp/otlptrace/internal/tracetransform/instrumentation_test.go
deleted file mode 100644
index 634d1dfa..00000000
--- a/exporters/otlp/otlptrace/internal/tracetransform/instrumentation_test.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright The OpenTelemetry Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package tracetransform // import "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal/tracetransform"
-
-import (
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-
-	"go.opentelemetry.io/otel/attribute"
-	"go.opentelemetry.io/otel/sdk/instrumentation"
-	commonpb "go.opentelemetry.io/proto/otlp/common/v1"
-)
-
-func TestInstrumentationScope(t *testing.T) {
-	t.Run("Empty", func(t *testing.T) {
-		assert.Nil(t, InstrumentationScope(instrumentation.Scope{}))
-	})
-
-	t.Run("Mapping", func(t *testing.T) {
-		var (
-			name    = "instrumentation name"
-			version = "v0.1.0"
-			attr    = attribute.NewSet(attribute.String("domain", "trace"))
-			attrPb  = Iterator(attr.Iter())
-		)
-		expected := &commonpb.InstrumentationScope{
-			Name:       name,
-			Version:    version,
-			Attributes: attrPb,
-		}
-		actual := InstrumentationScope(instrumentation.Scope{
-			Name:       name,
-			Version:    version,
-			SchemaURL:  "http://this.is.mapped.elsewhere.com",
-			Attributes: attr,
-		})
-		assert.Equal(t, expected, actual)
-	})
-}
diff --git a/exporters/stdout/stdouttrace/trace_test.go b/exporters/stdout/stdouttrace/trace_test.go
index 82bd2fca..649312bf 100644
--- a/exporters/stdout/stdouttrace/trace_test.go
+++ b/exporters/stdout/stdouttrace/trace_test.go
@@ -186,8 +186,7 @@ func expectedJSON(now time.Time) string {
 	"InstrumentationLibrary": {
 		"Name": "",
 		"Version": "",
-		"SchemaURL": "",
-		"Attributes": null
+		"SchemaURL": ""
 	}
 }
 `
diff --git a/metric/config_test.go b/metric/config_test.go
deleted file mode 100644
index 359e14c0..00000000
--- a/metric/config_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright The OpenTelemetry Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package metric // import "go.opentelemetry.io/otel/metric"
-
-import (
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-
-	"go.opentelemetry.io/otel/attribute"
-)
-
-func TestMeterConfig(t *testing.T) {
-	t.Run("Empty", func(t *testing.T) {
-		assert.Equal(t, NewMeterConfig(), MeterConfig{})
-	})
-
-	t.Run("InstrumentationVersion", func(t *testing.T) {
-		v0, v1 := "v0.1.0", "v1.0.0"
-
-		assert.Equal(t, NewMeterConfig(
-			WithInstrumentationVersion(v0),
-		).InstrumentationVersion(), v0)
-
-		assert.Equal(t, NewMeterConfig(
-			WithInstrumentationVersion(v0),
-			WithInstrumentationVersion(v1),
-		).InstrumentationVersion(), v1, "last option has precedence")
-	})
-
-	t.Run("SchemaURL", func(t *testing.T) {
-		s120 := "https://opentelemetry.io/schemas/1.2.0"
-		s130 := "https://opentelemetry.io/schemas/1.3.0"
-
-		assert.Equal(t, NewMeterConfig(
-			WithSchemaURL(s120),
-		).SchemaURL(), s120)
-
-		assert.Equal(t, NewMeterConfig(
-			WithSchemaURL(s120),
-			WithSchemaURL(s130),
-		).SchemaURL(), s130, "last option has precedence")
-	})
-
-	t.Run("Attributes", func(t *testing.T) {
-		one, two := attribute.Int("key", 1), attribute.Int("key", 2)
-
-		assert.Equal(t, NewMeterConfig(
-			WithScopeAttributes(one, two),
-		).Attributes(), attribute.NewSet(two), "last attribute is used")
-
-		assert.Equal(t, NewMeterConfig(
-			WithScopeAttributes(two),
-			WithScopeAttributes(one),
-		).Attributes(), attribute.NewSet(one), "last option has precedence")
-	})
-}
diff --git a/sdk/trace/trace_test.go b/sdk/trace/trace_test.go
index 8badccc4..c6adbb77 100644
--- a/sdk/trace/trace_test.go
+++ b/sdk/trace/trace_test.go
@@ -911,8 +911,6 @@ func TestSetSpanStatusWithoutMessageWhenStatusIsNotError(t *testing.T) {
 func cmpDiff(x, y interface{}) string {
 	return cmp.Diff(x, y,
 		cmp.AllowUnexported(snapshot{}),
-		cmp.AllowUnexported(attribute.Set{}),
-		cmp.AllowUnexported(attribute.Distinct{}),
 		cmp.AllowUnexported(attribute.Value{}),
 		cmp.AllowUnexported(Event{}),
 		cmp.AllowUnexported(trace.TraceState{}))
diff --git a/trace/config_test.go b/trace/config_test.go
index d46a8e13..a4cafcbc 100644
--- a/trace/config_test.go
+++ b/trace/config_test.go
@@ -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
@@ -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...)