fn: lb-agent: Add Runner Scheduler/Execution Stats (#1107)

LB agent reports lb placer latency. It should also report
how long it took for the runner to initiate the call as
well as execution time inside the container if the runner
has accepted (committed) to the call.
This commit is contained in:
Tolga Ceylan
2018-07-02 17:15:43 -07:00
committed by GitHub
parent e0ae9cc679
commit 317de18e6b
8 changed files with 172 additions and 53 deletions

View File

@@ -233,6 +233,29 @@ func tryQueueError(err error, done chan error) {
}
}
func translateDate(dt string) time.Time {
if dt != "" {
trx, err := common.ParseDateTime(dt)
if err == nil {
return time.Time(trx)
}
}
return time.Time{}
}
func recordFinishStats(ctx context.Context, msg *pb.CallFinished) {
creatTs := translateDate(msg.GetCreatedAt())
startTs := translateDate(msg.GetStartedAt())
complTs := translateDate(msg.GetCompletedAt())
// Validate this as info *is* coming from runner and its local clock.
if !creatTs.IsZero() && !startTs.IsZero() && !complTs.IsZero() && !startTs.Before(creatTs) && !complTs.Before(startTs) {
statsLBAgentRunnerSchedLatency(ctx, startTs.Sub(creatTs))
statsLBAgentRunnerExecLatency(ctx, complTs.Sub(startTs))
}
}
func receiveFromRunner(ctx context.Context, protocolClient pb.RunnerProtocol_EngageClient, c pool.RunnerCall, done chan error) {
w := c.ResponseWriter()
defer close(done)
@@ -286,6 +309,7 @@ DataLoop:
// Finish messages required for finish/finalize the processing.
case *pb.RunnerMsg_Finished:
log.Infof("Call finished Success=%v %v", body.Finished.Success, body.Finished.Details)
recordFinishStats(ctx, body.Finished)
if !body.Finished.Success {
err := parseError(body.Finished)
tryQueueError(err, done)