@@ -22,6 +22,9 @@ type SumoLogicAppender struct {
2222 eventsBatchSize int
2323 sumoPostMinimumDelay time.Duration
2424 timerBetweenPost time.Time
25+ sumoCategory string
26+ sumoName string
27+ sumoClient string
2528}
2629
2730type SumoBuffer struct {
@@ -30,14 +33,17 @@ type SumoBuffer struct {
3033 timerIdlebuffer time.Time
3134}
3235
33- func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue * eventQueue.Queue , eventsBatchSize int , sumoPostMinimumDelay time.Duration ) * SumoLogicAppender {
36+ func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue * eventQueue.Queue , eventsBatchSize int , sumoPostMinimumDelay time.Duration , sumoCategory string , sumoName string , sumoClient string ) * SumoLogicAppender {
3437 return & SumoLogicAppender {
3538 url : urlValue ,
3639 connectionTimeout : connectionTimeoutValue ,
3740 httpClient : http.Client {Timeout : time .Duration (connectionTimeoutValue * int (time .Millisecond ))},
3841 nozzleQueue : nozzleQueue ,
3942 eventsBatchSize : eventsBatchSize ,
4043 sumoPostMinimumDelay : sumoPostMinimumDelay ,
44+ sumoCategory : sumoCategory ,
45+ sumoName : sumoName ,
46+ sumoClient : sumoClient ,
4147 }
4248}
4349
@@ -115,7 +121,6 @@ func (s *SumoLogicAppender) AppendLogs(buffer *SumoBuffer) {
115121}
116122
117123func (s * SumoLogicAppender ) SendToSumo (logStringToSend string ) {
118-
119124 var buf bytes.Buffer
120125 g := gzip .NewWriter (& buf )
121126 g .Write ([]byte (logStringToSend ))
@@ -131,8 +136,18 @@ func (s *SumoLogicAppender) SendToSumo(logStringToSend string) {
131136 logging .Error .Printf ("http.NewRequest() error: %v\n " , err )
132137 return
133138 }
139+
134140 request .Header .Add ("Content-Encoding" , "gzip" )
135- //request.SetBasicAuth("admin", "admin")
141+
142+ if s .sumoName != "" {
143+ request .Header .Add ("X-Sumo-Name" , s .sumoName )
144+ }
145+ if s .sumoClient != "" {
146+ request .Header .Add ("X-Sumo-Client" , s .sumoClient )
147+ }
148+ if s .sumoCategory != "" {
149+ request .Header .Add ("X-Sumo-Category" , s .sumoCategory )
150+ }
136151 response , err := s .httpClient .Do (request )
137152
138153 if (err != nil ) || (response .StatusCode != 200 && response .StatusCode != 302 && response .StatusCode < 500 ) {
@@ -147,7 +162,18 @@ func (s *SumoLogicAppender) SendToSumo(logStringToSend string) {
147162 if err != nil {
148163 logging .Error .Printf ("http.NewRequest() error: %v\n " , err )
149164 }
165+ request .Header .Add ("X-Sumo-Name" , "HTTPTestString" )
150166 request .Header .Add ("Content-Encoding" , "gzip" )
167+
168+ if s .sumoName != "" {
169+ request .Header .Add ("X-Sumo-Name" , s .sumoName )
170+ }
171+ if s .sumoClient != "" {
172+ request .Header .Add ("X-Sumo-Client" , s .sumoClient )
173+ }
174+ if s .sumoCategory != "" {
175+ request .Header .Add ("X-Sumo-Category" , s .sumoCategory )
176+ }
151177 response , errRetry = s .httpClient .Do (request )
152178 if errRetry != nil {
153179 logging .Error .Printf ("http.Do() error: %v\n " , errRetry )
0 commit comments