Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otlplog: Add instrumentation scope attributes #5933

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/otlplog/otlploggrpc` adds instrumentation scope attributes. (#5933)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` adds instrumentation scope attributes. (#5933)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func ResourceLogs(records []log.Record) []*lpb.ResourceLogs {
var emptyScope instrumentation.Scope
if scope != emptyScope {
sl.Scope = &cpb.InstrumentationScope{
Name: scope.Name,
Version: scope.Version,
Name: scope.Name,
Version: scope.Version,
Attributes: AttrIter(scope.Attributes.Iter()),
}
sl.SchemaUrl = scope.SchemaURL
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
lpb "go.opentelemetry.io/proto/otlp/logs/v1"
rpb "go.opentelemetry.io/proto/otlp/resource/v1"

"go.opentelemetry.io/otel/attribute"
api "go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/log"
Expand Down Expand Up @@ -70,9 +71,10 @@ var (
flagsD = byte(0)

scope = instrumentation.Scope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
}
scope2 = instrumentation.Scope{
Name: "otel/test/code/path2",
Expand All @@ -84,6 +86,14 @@ var (
pbScope = &cpb.InstrumentationScope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
Attributes: []*cpb.KeyValue{
{
Key: "foo",
Value: &cpb.AnyValue{
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
}
pbScope2 = &cpb.InstrumentationScope{
Name: "otel/test/code/path2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func ResourceLogs(records []log.Record) []*lpb.ResourceLogs {
var emptyScope instrumentation.Scope
if scope != emptyScope {
sl.Scope = &cpb.InstrumentationScope{
Name: scope.Name,
Version: scope.Version,
Name: scope.Name,
Version: scope.Version,
Attributes: AttrIter(scope.Attributes.Iter()),
}
sl.SchemaUrl = scope.SchemaURL
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
lpb "go.opentelemetry.io/proto/otlp/logs/v1"
rpb "go.opentelemetry.io/proto/otlp/resource/v1"

"go.opentelemetry.io/otel/attribute"
api "go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/log"
Expand Down Expand Up @@ -70,9 +71,10 @@ var (
flagsD = byte(0)

scope = instrumentation.Scope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
}
scope2 = instrumentation.Scope{
Name: "otel/test/code/path2",
Expand All @@ -84,6 +86,14 @@ var (
pbScope = &cpb.InstrumentationScope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
Attributes: []*cpb.KeyValue{
{
Key: "foo",
Value: &cpb.AnyValue{
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
}
pbScope2 = &cpb.InstrumentationScope{
Name: "otel/test/code/path2",
Expand Down
5 changes: 3 additions & 2 deletions internal/shared/otlp/otlplog/transform/log.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func ResourceLogs(records []log.Record) []*lpb.ResourceLogs {
var emptyScope instrumentation.Scope
if scope != emptyScope {
sl.Scope = &cpb.InstrumentationScope{
Name: scope.Name,
Version: scope.Version,
Name: scope.Name,
Version: scope.Version,
Attributes: AttrIter(scope.Attributes.Iter()),
}
sl.SchemaUrl = scope.SchemaURL
}
Expand Down
16 changes: 13 additions & 3 deletions internal/shared/otlp/otlplog/transform/log_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
lpb "go.opentelemetry.io/proto/otlp/logs/v1"
rpb "go.opentelemetry.io/proto/otlp/resource/v1"

"go.opentelemetry.io/otel/attribute"
api "go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/log"
Expand Down Expand Up @@ -70,9 +71,10 @@ var (
flagsD = byte(0)

scope = instrumentation.Scope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Name: "otel/test/code/path1",
Version: "v0.1.1",
SchemaURL: semconv.SchemaURL,
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
}
scope2 = instrumentation.Scope{
Name: "otel/test/code/path2",
Expand All @@ -84,6 +86,14 @@ var (
pbScope = &cpb.InstrumentationScope{
Name: "otel/test/code/path1",
Version: "v0.1.1",
Attributes: []*cpb.KeyValue{
{
Key: "foo",
Value: &cpb.AnyValue{
Value: &cpb.AnyValue_StringValue{StringValue: "bar"},
},
},
},
}
pbScope2 = &cpb.InstrumentationScope{
Name: "otel/test/code/path2",
Expand Down
Loading