@@ -2,17 +2,14 @@ package eventRouting
22
33import (
44 "fmt"
5- "os"
65 "sort"
76 "strings"
87 "sync"
98 "time"
109
1110 "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/caching"
1211 fevents "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/events"
13- "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/extrafields"
14- "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging"
15- "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/sumoCFFirehose" //**
12+ "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/sumoCFFirehose"
1613 "github.com/Sirupsen/logrus"
1714 "github.com/cloudfoundry/sonde-go/events"
1815)
@@ -23,19 +20,17 @@ type EventRouting struct {
2320 selectedEventsCount map [string ]uint64
2421 mutex * sync.Mutex
2522 sLAppender sumoCFFirehose.SumoCFFirehose //**
26- log logging.Logging
27- ExtraFields map [string ]string
23+ //*log logging.Logging
2824}
2925
30- func NewEventRouting (caching caching.Caching , logging logging. Logging , sLAppender sumoCFFirehose.SumoCFFirehose ) * EventRouting {
26+ func NewEventRouting (caching caching.Caching , sLAppender sumoCFFirehose.SumoCFFirehose ) * EventRouting {
3127 return & EventRouting {
3228 CachingClient : caching ,
3329 selectedEvents : make (map [string ]bool ),
3430 selectedEventsCount : make (map [string ]uint64 ),
3531 sLAppender : sLAppender , //**
36- log : logging ,
37- mutex : & sync.Mutex {},
38- ExtraFields : make (map [string ]string ),
32+ //* log: logging,
33+ mutex : & sync.Mutex {},
3934 }
4035}
4136
@@ -70,7 +65,6 @@ func (e *EventRouting) RouteEvent(msg *events.Envelope) {
7065
7166 event .AnnotateWithEnveloppeData (msg )
7267
73- event .AnnotateWithMetaData (e .ExtraFields )
7468 if _ , hasAppId := event .Fields ["cf_app_id" ]; hasAppId {
7569 event .AnnotateWithAppData (e .CachingClient )
7670 }
@@ -80,8 +74,10 @@ func (e *EventRouting) RouteEvent(msg *events.Envelope) {
8074 if ignored , hasIgnoredField := event .Fields ["cf_ignored_app" ]; ignored == true && hasIgnoredField {
8175 e .selectedEventsCount ["ignored_app_message" ]++
8276 } else {
83- e .sLAppender .AppendLogs (event .Fields ) //**
84- e .log .ShipEvents (event .Fields , event .Msg ) // here we have to change the method for the one on sumoLogicAppender
77+ /*fmt.Printf("I'm in eventRpouting method .. -------")
78+ fmt.Println(event.Fields)
79+ fmt.Println(event.Msg)*/
80+ e .sLAppender .AppendLogs (event .Fields ) //**/here we have to change the method for the one on sumoLogicAppender
8581 e .selectedEventsCount [eventType .String ()]++
8682
8783 }
@@ -97,7 +93,7 @@ func (e *EventRouting) SetupEventRouting(wantedEvents string) error {
9793 for _ , event := range strings .Split (wantedEvents , "," ) {
9894 if e .isAuthorizedEvent (strings .TrimSpace (event )) {
9995 e .selectedEvents [strings .TrimSpace (event )] = true
100- logging .LogStd (fmt .Sprintf ("Event Type [%s] is included in the fireshose!" , event ), false )
96+ // logging.LogStd(fmt.Sprintf("Event Type [%s] is included in the fireshose!", event), false)
10197 } else {
10298 return fmt .Errorf ("Rejected Event Name [%s] - Valid events: %s" , event , GetListAuthorizedEventEvents ())
10399 }
@@ -106,16 +102,6 @@ func (e *EventRouting) SetupEventRouting(wantedEvents string) error {
106102 return nil
107103}
108104
109- func (e * EventRouting ) SetExtraFields (extraEventsString string ) {
110- // Parse extra fields from cmd call
111- extraFields , err := extrafields .ParseExtraFields (extraEventsString )
112- if err != nil {
113- logging .LogError ("Error parsing extra fields: " , err )
114- os .Exit (1 )
115- }
116- e .ExtraFields = extraFields
117- }
118-
119105func (e * EventRouting ) isAuthorizedEvent (wantedEvent string ) bool {
120106 for _ , authorizeEvent := range events .Envelope_EventType_name {
121107 if wantedEvent == authorizeEvent {
@@ -159,7 +145,8 @@ func (e *EventRouting) LogEventTotals(logTotalsTime time.Duration) {
159145 startTime = time .Now ()
160146 event , lastCount := e .getEventTotals (totalElapsedTime , elapsedTime , count )
161147 count = lastCount
162- e .log .ShipEvents (event .Fields , event .Msg )
148+ //*e.log.ShipEvents(event.Fields, event.Msg)
149+ e .sLAppender .AppendLogs (event .Fields )
163150 }
164151 }()
165152}
0 commit comments