Skip to content

Commit

Permalink
otlptrace: Add instrumentation scope attributes (#5934)
Browse files Browse the repository at this point in the history
Towards #5844
  • Loading branch information
pellared authored Oct 31, 2024
1 parent 3cc4857 commit 692cb35
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/otlptrace/otlptracegrpc` adds instrumentation scope attributes. (#5934)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` adds instrumentation scope attributes. (#5934)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ func InstrumentationScope(il instrumentation.Scope) *commonpb.InstrumentationSco
return nil
}
return &commonpb.InstrumentationScope{
Name: il.Name,
Version: il.Version,
Name: il.Name,
Version: il.Version,
Attributes: Iterator(il.Attributes.Iter()),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package 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) {
want := &commonpb.InstrumentationScope{
Name: "name",
Version: "1.0.0",
Attributes: []*commonpb.KeyValue{
{
Key: "foo",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
}

in := instrumentation.Scope{
Name: "name",
Version: "1.0.0",
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
}

got := InstrumentationScope(in)

assert.Equal(t, want, got)
}

0 comments on commit 692cb35

Please sign in to comment.