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

[internal/stanza] Add support for []string in converter.go #9887

Merged
merged 3 commits into from
May 10, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- `tanzuobservabilityexporter`: Make metrics stanza in config be optional (#9098)
- `filelogreceiver`: Update Kubernetes examples to fix native OTel logs collection issue where 0 length logs cause errors (#9754)
- `logstransformprocessor`: Resolve node ordering to fix intermittent failures (#9761)
- `filelog`, `journald`, `syslog`, `tcplog`, `udplog`: Add support for []string type for converting log record entries (#9887)

## v0.50.0

Expand Down
15 changes: 15 additions & 0 deletions internal/stanza/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ func insertToAttributeVal(value interface{}, dest pcommon.Value) {
dest.SetBoolVal(t)
case string:
dest.SetStringVal(t)
case []string:
toStringArray(t).CopyTo(dest)
case []byte:
dest.SetBytesVal(t)
case int64:
Expand Down Expand Up @@ -420,6 +422,9 @@ func insertToAttributeMap(obsMap map[string]interface{}, dest pcommon.Map) {
dest.InsertBool(k, t)
case string:
dest.InsertString(k, t)
case []string:
arr := toStringArray(t)
dest.Insert(k, arr)
case []byte:
dest.InsertBytes(k, t)
case int64:
Expand Down Expand Up @@ -468,6 +473,16 @@ func toAttributeArray(obsArr []interface{}) pcommon.Value {
return arrVal
}

func toStringArray(strArr []string) pcommon.Value {
arrVal := pcommon.NewValueSlice()
arr := arrVal.SliceVal()
arr.EnsureCapacity(len(strArr))
for _, v := range strArr {
insertToAttributeVal(v, arr.AppendEmpty())
}
return arrVal
}

var sevMap = map[entry.Severity]plog.SeverityNumber{
entry.Default: plog.SeverityNumberUNDEFINED,
entry.Trace: plog.SeverityNumberTRACE,
Expand Down