Skip to content

Commit

Permalink
otlpmetric: Add instrumentation scope attributes (#5935)
Browse files Browse the repository at this point in the history
Towards #5844
  • Loading branch information
pellared authored Oct 31, 2024
1 parent 692cb35 commit afd1311
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Add `Attributes attribute.Set` field to `ScopeRecords` in `go.opentelemetry.io/otel/log/logtest`. (#5927)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` adds instrumentation scope attributes. (#5934)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` adds instrumentation scope attributes. (#5934)
- `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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions internal/shared/otlp/otlpmetric/transform/metricdata.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions internal/shared/otlp/otlpmetric/transform/metricdata_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
Expand Down

0 comments on commit afd1311

Please sign in to comment.