@@ -82,8 +82,13 @@ func FireCampaignEvent(
82
82
83
83
// StartFlow runs the passed in flow for the passed in contact
84
84
func StartFlow (ctx context.Context , db * sqlx.DB , rp * redis.Pool , org * models.OrgAssets , assets flows.SessionAssets , tgs []flows.Trigger ) ([]* models.Session , error ) {
85
+ if len (tgs ) == 0 {
86
+ return nil , nil
87
+ }
88
+
85
89
track := models .NewTrack (ctx , db , rp , org )
86
90
start := time .Now ()
91
+ log := logrus .WithField ("flow_name" , tgs [0 ].Flow ().Name ).WithField ("flow_uuid" , tgs [0 ].Flow ().UUID )
87
92
88
93
// for each trigger start the flow
89
94
sessions := make ([]flows.Session , 0 , len (tgs ))
@@ -92,12 +97,14 @@ func StartFlow(ctx context.Context, db *sqlx.DB, rp *redis.Pool, org *models.Org
92
97
session := engine .NewSession (assets , engine .NewDefaultConfig (), httpClient )
93
98
94
99
// start our flow
100
+ log := logrus .WithField ("contact_uuid" , trigger .Contact ().UUID ())
95
101
start := time .Now ()
96
102
err := session .Start (trigger , nil )
97
103
if err != nil {
98
- logrus . WithField ( "contact_id" , trigger . Contact (). ID ()). WithError (err ).Errorf ("error starting flow: %s" , trigger . Flow (). UUID )
104
+ log . WithError (err ).Errorf ("error starting flow" )
99
105
continue
100
106
}
107
+ log .WithField ("elapsed" , time .Since (start )).Info ("flow engine start" )
101
108
librato .Gauge ("mr.flow_start_elapsed" , float64 (time .Since (start )))
102
109
103
110
sessions = append (sessions , session )
@@ -177,6 +184,7 @@ func StartFlow(ctx context.Context, db *sqlx.DB, rp *redis.Pool, org *models.Org
177
184
// figure out both average and total for total execution and commit time for our flows
178
185
librato .Gauge ("mr.flow_start_elapsed" , float64 (time .Since (start ))/ float64 (time .Second ))
179
186
librato .Gauge ("mr.flow_start_count" , float64 (len (dbSessions )))
187
+ log .WithField ("elapsed" , time .Since (start )).WithField ("count" , len (dbSessions )).Info ("flows started, sessions created" )
180
188
181
189
return dbSessions , nil
182
190
}
0 commit comments