From 21f02714f952f4a14f14d347dbff655f14d9e15a Mon Sep 17 00:00:00 2001 From: smithclay Date: Thu, 13 Jun 2024 15:24:33 -0700 Subject: [PATCH] update event payload to send JSON object --- collector/components/servicenowexporter/servicenow.go | 9 ++------- .../components/servicenowexporter/servicenow_event.go | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/collector/components/servicenowexporter/servicenow.go b/collector/components/servicenowexporter/servicenow.go index 1a5104d..dd85dd7 100644 --- a/collector/components/servicenowexporter/servicenow.go +++ b/collector/components/servicenowexporter/servicenow.go @@ -3,7 +3,6 @@ package servicenowexporter import ( "bytes" "context" - "encoding/json" "strconv" "strings" @@ -362,7 +361,7 @@ func buildPath(name string, attributes pcommon.Map) string { return buf.String() } -func formatAdditionalInfo(attrs map[string]string, resourceAttrs map[string]string) (string, error) { +func formatAdditionalInfo(attrs map[string]string, resourceAttrs map[string]string) (map[string]string, error) { // merge attrs + resource attrs newAttrs := make(map[string]string) for k, v := range resourceAttrs { @@ -383,11 +382,7 @@ func formatAdditionalInfo(attrs map[string]string, resourceAttrs map[string]stri newAttrs[k] = v } - bytes, err := json.Marshal(newAttrs) - if err != nil { - return "", err - } - return string(bytes), nil + return newAttrs, nil } func formatNode(resourceAttrs map[string]string) string { diff --git a/collector/components/servicenowexporter/servicenow_event.go b/collector/components/servicenowexporter/servicenow_event.go index 3447f80..f1ae84c 100644 --- a/collector/components/servicenowexporter/servicenow_event.go +++ b/collector/components/servicenowexporter/servicenow_event.go @@ -15,6 +15,6 @@ type ServiceNowEvent struct { Description string `json:"description"` Timestamp string `json:"time_of_event"` // yyyy-MM-dd HH:mm:ss // k8s.cluster.name:test-cluster,k8s.cluster.uid=12345 - AdditionalInfo string `json:"additional_info,omitempty"` // actually a json string - Source string `json:"source"` + AdditionalInfo map[string]string `json:"additional_info,omitempty"` // actually a json string + Source string `json:"source"` }