Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions bridges/otellogr/convert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bridges/otellogr/convert_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions bridges/otellogrus/convert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bridges/otellogrus/convert_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions bridges/otellogrus/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ func TestConvertFields(t *testing.T) {
log.String("hello", "{Name:foobar}"),
},
},
{
name: "with standard attribute",
fields: logrus.Fields{"hello": attribute.StringSliceValue([]string{"foo", "bar"})},
want: []log.KeyValue{
log.Slice("hello", log.StringValue("foo"), log.StringValue("bar")),
},
},
} {
t.Run(tt.name, func(t *testing.T) {
got := convertFields(tt.fields)
Expand Down
5 changes: 5 additions & 0 deletions bridges/otelslog/convert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bridges/otelslog/convert_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions bridges/otelzap/convert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions bridges/otelzap/convert_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/shared/logutil/convert.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"strconv"
"time"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
)

Expand Down Expand Up @@ -66,6 +67,10 @@ func convertValue(v any) log.Value {
return log.BytesValue(val)
case error:
return log.StringValue(val.Error())
case attribute.Value:
return log.ValueFromAttribute(val)
case log.Value:
return val
}

t := reflect.TypeOf(v)
Expand Down
11 changes: 11 additions & 0 deletions internal/shared/logutil/convert_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
)

Expand Down Expand Up @@ -245,6 +246,16 @@ func TestConvertValue(t *testing.T) {
value: context.Background(),
wantValue: log.StringValue("context.Background"),
},
{
name: "standard attribute",
value: attribute.StringSliceValue([]string{"foo", "bar"}),
wantValue: log.SliceValue(log.StringValue("foo"), log.StringValue("bar")),
},
{
name: "log attribute",
value: log.SliceValue(log.StringValue("foo"), log.Int64Value(123)),
wantValue: log.SliceValue(log.StringValue("foo"), log.Int64Value(123)),
},
{
name: "unhandled type",
value: chan int(nil),
Expand Down
Loading