Skip to content

Commit afd1311

Browse files
authored
otlpmetric: Add instrumentation scope attributes (#5935)
Towards #5844
1 parent 692cb35 commit afd1311

File tree

7 files changed

+47
-15
lines changed

7 files changed

+47
-15
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2121
- Add `Attributes attribute.Set` field to `ScopeRecords` in `go.opentelemetry.io/otel/log/logtest`. (#5927)
2222
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` adds instrumentation scope attributes. (#5934)
2323
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` adds instrumentation scope attributes. (#5934)
24+
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` adds instrumentation scope attributes. (#5935)
25+
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp` adds instrumentation scope attributes. (#5935)
2426

2527
### Fixed
2628

exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) {
4646

4747
out = append(out, &mpb.ScopeMetrics{
4848
Scope: &cpb.InstrumentationScope{
49-
Name: sm.Scope.Name,
50-
Version: sm.Scope.Version,
49+
Name: sm.Scope.Name,
50+
Version: sm.Scope.Version,
51+
Attributes: AttrIter(sm.Scope.Attributes.Iter()),
5152
},
5253
Metrics: ms,
5354
SchemaUrl: sm.Scope.SchemaURL,

exporters/otlp/otlpmetric/otlpmetricgrpc/internal/transform/metricdata_test.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,10 @@ var (
805805
otelScopeMetrics = []metricdata.ScopeMetrics{
806806
{
807807
Scope: instrumentation.Scope{
808-
Name: "test/code/path",
809-
Version: "v0.1.0",
810-
SchemaURL: semconv.SchemaURL,
808+
Name: "test/code/path",
809+
Version: "v0.1.0",
810+
SchemaURL: semconv.SchemaURL,
811+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
811812
},
812813
Metrics: otelMetrics,
813814
},
@@ -818,6 +819,14 @@ var (
818819
Scope: &cpb.InstrumentationScope{
819820
Name: "test/code/path",
820821
Version: "v0.1.0",
822+
Attributes: []*cpb.KeyValue{
823+
{
824+
Key: "foo",
825+
Value: &cpb.AnyValue{
826+
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
827+
},
828+
},
829+
},
821830
},
822831
Metrics: pbMetrics,
823832
SchemaUrl: semconv.SchemaURL,

exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) {
4646

4747
out = append(out, &mpb.ScopeMetrics{
4848
Scope: &cpb.InstrumentationScope{
49-
Name: sm.Scope.Name,
50-
Version: sm.Scope.Version,
49+
Name: sm.Scope.Name,
50+
Version: sm.Scope.Version,
51+
Attributes: AttrIter(sm.Scope.Attributes.Iter()),
5152
},
5253
Metrics: ms,
5354
SchemaUrl: sm.Scope.SchemaURL,

exporters/otlp/otlpmetric/otlpmetrichttp/internal/transform/metricdata_test.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,10 @@ var (
805805
otelScopeMetrics = []metricdata.ScopeMetrics{
806806
{
807807
Scope: instrumentation.Scope{
808-
Name: "test/code/path",
809-
Version: "v0.1.0",
810-
SchemaURL: semconv.SchemaURL,
808+
Name: "test/code/path",
809+
Version: "v0.1.0",
810+
SchemaURL: semconv.SchemaURL,
811+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
811812
},
812813
Metrics: otelMetrics,
813814
},
@@ -818,6 +819,14 @@ var (
818819
Scope: &cpb.InstrumentationScope{
819820
Name: "test/code/path",
820821
Version: "v0.1.0",
822+
Attributes: []*cpb.KeyValue{
823+
{
824+
Key: "foo",
825+
Value: &cpb.AnyValue{
826+
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
827+
},
828+
},
829+
},
821830
},
822831
Metrics: pbMetrics,
823832
SchemaUrl: semconv.SchemaURL,

internal/shared/otlp/otlpmetric/transform/metricdata.go.tmpl

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func ScopeMetrics(sms []metricdata.ScopeMetrics) ([]*mpb.ScopeMetrics, error) {
4646

4747
out = append(out, &mpb.ScopeMetrics{
4848
Scope: &cpb.InstrumentationScope{
49-
Name: sm.Scope.Name,
50-
Version: sm.Scope.Version,
49+
Name: sm.Scope.Name,
50+
Version: sm.Scope.Version,
51+
Attributes: AttrIter(sm.Scope.Attributes.Iter()),
5152
},
5253
Metrics: ms,
5354
SchemaUrl: sm.Scope.SchemaURL,

internal/shared/otlp/otlpmetric/transform/metricdata_test.go.tmpl

+12-3
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,10 @@ var (
805805
otelScopeMetrics = []metricdata.ScopeMetrics{
806806
{
807807
Scope: instrumentation.Scope{
808-
Name: "test/code/path",
809-
Version: "v0.1.0",
810-
SchemaURL: semconv.SchemaURL,
808+
Name: "test/code/path",
809+
Version: "v0.1.0",
810+
SchemaURL: semconv.SchemaURL,
811+
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
811812
},
812813
Metrics: otelMetrics,
813814
},
@@ -818,6 +819,14 @@ var (
818819
Scope: &cpb.InstrumentationScope{
819820
Name: "test/code/path",
820821
Version: "v0.1.0",
822+
Attributes: []*cpb.KeyValue{
823+
{
824+
Key: "foo",
825+
Value: &cpb.AnyValue{
826+
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
827+
},
828+
},
829+
},
821830
},
822831
Metrics: pbMetrics,
823832
SchemaUrl: semconv.SchemaURL,

0 commit comments

Comments
 (0)