feat: log step elapsed in seconds

This commit is contained in:
lilong.129
2023-06-23 23:06:56 +08:00
parent 0c8d86639b
commit 1033ba77d7
2 changed files with 13 additions and 9 deletions

View File

@@ -248,7 +248,7 @@ func (s *veDEMImageService) GetImage(imageBuf *bytes.Buffer) (
log.Debug().
Str("X-TT-LOGID", logID).
Int("image_bytes", size).
Float64("elapsed_seconds", elapsed.Seconds()).
Float64("elapsed(s)", elapsed.Seconds()).
Msg("request OCR service success")
break
}

View File

@@ -539,8 +539,9 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
parsedName = step.Name()
}
stepName := convertString(parsedName)
log.Info().Str("step", stepName).
Str("type", string(step.Type())).Msg("run step start")
stepType := string(step.Type())
log.Info().Str("step", stepName).Str("type", stepType).Msg("run step start")
stepStartTime := time.Now()
// run times of step
loopTimes := step.Struct().Loops
@@ -563,10 +564,10 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
}
// run step
stepStartTime := time.Now().Unix()
startTime := time.Now().Unix()
stepResult, err = step.Run(r)
stepResult.Name = stepName + loopIndex
stepResult.StartTime = stepStartTime
stepResult.StartTime = startTime
r.updateSummary(stepResult)
}
@@ -576,19 +577,22 @@ func (r *SessionRunner) Start(givenVars map[string]interface{}) error {
r.sessionVariables[k] = v
}
stepElapsed := time.Since(stepStartTime).Seconds()
if err == nil {
log.Info().Str("step", stepResult.Name).
Str("type", string(stepResult.StepType)).
log.Info().Str("step", stepName).
Str("type", stepType).
Bool("success", true).
Float64("elapsed(s)", stepElapsed).
Interface("exportVars", stepResult.ExportVars).
Msg("run step end")
continue
}
// failed
log.Error().Err(err).Str("step", stepResult.Name).
Str("type", string(stepResult.StepType)).
log.Error().Err(err).Str("step", stepName).
Str("type", stepType).
Bool("success", false).
Float64("elapsed(s)", stepElapsed).
Msg("run step end")
// interrupted or timeout, abort running