Skip to content

Commit

Permalink
Modify expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ebi-yade committed Nov 28, 2024
1 parent 7206147 commit bdf2f22
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/otel/attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package otel
import (
"encoding/json"
"fmt"

"reflect"
"time"

Expand Down Expand Up @@ -257,14 +256,14 @@ func marshalSlice(f structFiled, fv reflect.Value) ([]attribute.KeyValue, error)
}
return []attribute.KeyValue{attribute.StringSlice(f.attributeName, strs)}, nil
}
fallthrough // OpenTelemetry プロトコルのレベルで、そもそも合成型の配列は非対応のため、いずれにせよ文字列化以外の選択肢は与えない
default:
bs, err := json.Marshal(fv.Interface())
if err != nil {
return []attribute.KeyValue{}, err
}
return []attribute.KeyValue{attribute.String(f.attributeName, string(bs))}, nil
// There is no choice but to provide only stringification because composite arrays are not supported at the OpenTelemetry protocol level.
}
bs, err := json.Marshal(fv.Interface())
if err != nil {
return []attribute.KeyValue{}, err
}

return []attribute.KeyValue{attribute.String(f.attributeName, string(bs))}, nil
}

func reflectValueToSlice[T any](v reflect.Value) []T {
Expand Down

0 comments on commit bdf2f22

Please sign in to comment.