Skip to content

Commit

Permalink
update event payload to send JSON object
Browse files Browse the repository at this point in the history
  • Loading branch information
smithclay committed Jun 13, 2024
1 parent bfb44c2 commit 21f0271
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions collector/components/servicenowexporter/servicenow.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package servicenowexporter
import (
"bytes"
"context"
"encoding/json"
"strconv"
"strings"

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions collector/components/servicenowexporter/servicenow_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 21f0271

Please sign in to comment.