@@ -3,13 +3,13 @@ package sumoCFFirehose
33import (
44 "bytes"
55 "compress/gzip"
6+ "encoding/json"
67 "errors"
78 "net/http"
89 "runtime"
10+ "strings"
911 "time"
1012
11- "encoding/json"
12-
1313 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue"
1414 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/events"
1515 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/logging"
@@ -27,6 +27,7 @@ type SumoLogicAppender struct {
2727 sumoName string
2828 sumoHost string
2929 verboseLogMessages bool
30+ customMetadata string
3031}
3132
3233type SumoBuffer struct {
@@ -35,7 +36,7 @@ type SumoBuffer struct {
3536 timerIdlebuffer time.Time
3637}
3738
38- func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue * eventQueue.Queue , eventsBatchSize int , sumoPostMinimumDelay time.Duration , sumoCategory string , sumoName string , sumoHost string , verboseLogMessages bool ) * SumoLogicAppender {
39+ func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue * eventQueue.Queue , eventsBatchSize int , sumoPostMinimumDelay time.Duration , sumoCategory string , sumoName string , sumoHost string , verboseLogMessages bool , customMetadata string ) * SumoLogicAppender {
3940 return & SumoLogicAppender {
4041 url : urlValue ,
4142 connectionTimeout : connectionTimeoutValue ,
@@ -47,6 +48,7 @@ func NewSumoLogicAppender(urlValue string, connectionTimeoutValue int, nozzleQue
4748 sumoName : sumoName ,
4849 sumoHost : sumoHost ,
4950 verboseLogMessages : verboseLogMessages ,
51+ customMetadata : customMetadata ,
5052 }
5153}
5254
@@ -198,7 +200,6 @@ func (s *SumoLogicAppender) SendToSumo(logStringToSend string) {
198200 logging .Error .Printf ("http.NewRequest() error: %v\n " , err )
199201 return
200202 }
201-
202203 request .Header .Add ("Content-Encoding" , "gzip" )
203204
204205 if s .sumoName != "" {
@@ -210,6 +211,13 @@ func (s *SumoLogicAppender) SendToSumo(logStringToSend string) {
210211 if s .sumoCategory != "" {
211212 request .Header .Add ("X-Sumo-Category" , s .sumoCategory )
212213 }
214+
215+ if s .customMetadata != "" {
216+ cMetadataArray := strings .Split (s .customMetadata , "," )
217+ for i := 0 ; i < len (cMetadataArray ); i ++ {
218+ request .Header .Add (strings .Split (cMetadataArray [i ], ":" )[0 ], strings .Split (cMetadataArray [i ], ":" )[1 ])
219+ }
220+ }
213221 //checking the timer before first POST intent
214222 for time .Since (s .timerBetweenPost ) < s .sumoPostMinimumDelay {
215223 logging .Trace .Println ("Delaying Post because minimum post timer not expired" )
0 commit comments