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

Do the appeasing #332

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion processor/loghouseprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func promoteResourceAttrs(l *plog.LogRecord, rlogs *plog.ResourceLogs) {
return
}
merged := MergeRawMaps(rlogs.Resource().Attributes().AsRaw(), attributes.Map().AsRaw())
rlogs.Resource().Attributes().FromRaw(merged)
_ = rlogs.Resource().Attributes().FromRaw(merged)
}

// MergeRawMaps merges n maps with a later map's keys overriding earlier maps. (copied to avoid dep hell)
Expand Down
17 changes: 8 additions & 9 deletions processor/loghouseprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ package loghouseprocessor
import (
"testing"

"go.opentelemetry.io/collector/pdata/pcommon"

"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
)

Expand Down Expand Up @@ -291,7 +290,7 @@ func Test_promoteResourceAttrs(t *testing.T) {
t.Run("single log", func(t *testing.T) {
rl := plog.NewResourceLogs()
l := plog.NewLogRecord()
l.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})
_ = l.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})

promoteResourceAttrs(&l, &rl)

Expand All @@ -303,9 +302,9 @@ func Test_promoteResourceAttrs(t *testing.T) {
t.Run("two logs", func(t *testing.T) {
rl := plog.NewResourceLogs()
l1 := plog.NewLogRecord()
l1.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})
_ = l1.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})
l2 := plog.NewLogRecord()
l2.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r2": "v2"}})
_ = l2.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r2": "v2"}})

promoteResourceAttrs(&l1, &rl)
promoteResourceAttrs(&l2, &rl)
Expand All @@ -322,9 +321,9 @@ func Test_promoteResourceAttrs(t *testing.T) {
t.Run("last wins", func(t *testing.T) {
rl := plog.NewResourceLogs()
l1 := plog.NewLogRecord()
l1.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})
_ = l1.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})
l2 := plog.NewLogRecord()
l2.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v2"}})
_ = l2.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v2"}})

promoteResourceAttrs(&l1, &rl)
promoteResourceAttrs(&l2, &rl)
Expand All @@ -336,9 +335,9 @@ func Test_promoteResourceAttrs(t *testing.T) {

t.Run("overwrite original", func(t *testing.T) {
rl := plog.NewResourceLogs()
rl.Resource().Attributes().FromRaw(map[string]any{"r1": "original"})
_ = rl.Resource().Attributes().FromRaw(map[string]any{"r1": "original"})
l1 := plog.NewLogRecord()
l1.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})
_ = l1.Attributes().FromRaw(map[string]any{"resource": map[string]any{"r1": "v1"}})

promoteResourceAttrs(&l1, &rl)

Expand Down
Loading