diff --git a/CHANGELOG.md b/CHANGELOG.md index eab1919f403..78476958b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm The package contains semantic conventions from the `v1.27.0` version of the OpenTelemetry Semantic Conventions. (#5894) - Add `Attributes attribute.Set` field to `Scope` in `go.opentelemetry.io/otel/sdk/instrumentation`. (#5903) - Add `Attributes attribute.Set` field to `ScopeRecords` in `go.opentelemetry.io/otel/log/logtest`. (#5927) +- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` adds instrumentation scope attributes. (#5935) +- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` adds instrumentation scope attributes. (#5935) ### Fixed diff --git a/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata.go b/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata.go index e13dfdca505..abf7f021960 100644 --- a/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata.go +++ b/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata.go @@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) { out = append(out, &mpb.ScopeMetrics{ Scope: &cpb.InstrumentationScope{ - Name: sm.Scope.Name, - Version: sm.Scope.Version, + Name: sm.Scope.Name, + Version: sm.Scope.Version, + Attributes: AttrIter(sm.Scope.Attributes.Iter()), }, Metrics: ms, SchemaUrl: sm.Scope.SchemaURL, diff --git a/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata_test.go b/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata_test.go index 1648fff2d78..d10b00257f9 100644 --- a/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata_test.go +++ b/exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata_test.go @@ -805,9 +805,10 @@ var ( otelScopeMetrics = []metricdata.ScopeMetrics{ { Scope: instrumentation.Scope{ - Name: "test/code/path", - Version: "v0.1.0", - SchemaURL: semconv.SchemaURL, + Name: "test/code/path", + Version: "v0.1.0", + SchemaURL: semconv.SchemaURL, + Attributes: attribute.NewSet(attribute.String("foo", "bar")), }, Metrics: otelMetrics, }, @@ -818,6 +819,14 @@ var ( Scope: &cpb.InstrumentationScope{ Name: "test/code/path", Version: "v0.1.0", + Attributes: []*cpb.KeyValue{ + { + Key: "foo", + Value: &cpb.AnyValue{ + Value: &cpb.AnyValue_StringValue{StringValue: "bar"}, + }, + }, + }, }, Metrics: pbMetrics, SchemaUrl: semconv.SchemaURL, diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata.go b/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata.go index bede7e85171..8207b15a421 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata.go +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata.go @@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) { out = append(out, &mpb.ScopeMetrics{ Scope: &cpb.InstrumentationScope{ - Name: sm.Scope.Name, - Version: sm.Scope.Version, + Name: sm.Scope.Name, + Version: sm.Scope.Version, + Attributes: AttrIter(sm.Scope.Attributes.Iter()), }, Metrics: ms, SchemaUrl: sm.Scope.SchemaURL, diff --git a/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata_test.go b/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata_test.go index 1648fff2d78..d10b00257f9 100644 --- a/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata_test.go +++ b/exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata_test.go @@ -805,9 +805,10 @@ var ( otelScopeMetrics = []metricdata.ScopeMetrics{ { Scope: instrumentation.Scope{ - Name: "test/code/path", - Version: "v0.1.0", - SchemaURL: semconv.SchemaURL, + Name: "test/code/path", + Version: "v0.1.0", + SchemaURL: semconv.SchemaURL, + Attributes: attribute.NewSet(attribute.String("foo", "bar")), }, Metrics: otelMetrics, }, @@ -818,6 +819,14 @@ var ( Scope: &cpb.InstrumentationScope{ Name: "test/code/path", Version: "v0.1.0", + Attributes: []*cpb.KeyValue{ + { + Key: "foo", + Value: &cpb.AnyValue{ + Value: &cpb.AnyValue_StringValue{StringValue: "bar"}, + }, + }, + }, }, Metrics: pbMetrics, SchemaUrl: semconv.SchemaURL, diff --git a/internal/shared/otlp/otlpmetric/transform/metricdata.go.tmpl b/internal/shared/otlp/otlpmetric/transform/metricdata.go.tmpl index 313d08cd16c..d11ee433181 100644 --- a/internal/shared/otlp/otlpmetric/transform/metricdata.go.tmpl +++ b/internal/shared/otlp/otlpmetric/transform/metricdata.go.tmpl @@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) { out = append(out, &mpb.ScopeMetrics{ Scope: &cpb.InstrumentationScope{ - Name: sm.Scope.Name, - Version: sm.Scope.Version, + Name: sm.Scope.Name, + Version: sm.Scope.Version, + Attributes: AttrIter(sm.Scope.Attributes.Iter()), }, Metrics: ms, SchemaUrl: sm.Scope.SchemaURL, diff --git a/internal/shared/otlp/otlpmetric/transform/metricdata_test.go.tmpl b/internal/shared/otlp/otlpmetric/transform/metricdata_test.go.tmpl index 1648fff2d78..d10b00257f9 100644 --- a/internal/shared/otlp/otlpmetric/transform/metricdata_test.go.tmpl +++ b/internal/shared/otlp/otlpmetric/transform/metricdata_test.go.tmpl @@ -805,9 +805,10 @@ var ( otelScopeMetrics = []metricdata.ScopeMetrics{ { Scope: instrumentation.Scope{ - Name: "test/code/path", - Version: "v0.1.0", - SchemaURL: semconv.SchemaURL, + Name: "test/code/path", + Version: "v0.1.0", + SchemaURL: semconv.SchemaURL, + Attributes: attribute.NewSet(attribute.String("foo", "bar")), }, Metrics: otelMetrics, }, @@ -818,6 +819,14 @@ var ( Scope: &cpb.InstrumentationScope{ Name: "test/code/path", Version: "v0.1.0", + Attributes: []*cpb.KeyValue{ + { + Key: "foo", + Value: &cpb.AnyValue{ + Value: &cpb.AnyValue_StringValue{StringValue: "bar"}, + }, + }, + }, }, Metrics: pbMetrics, SchemaUrl: semconv.SchemaURL,