count duration for attempt

This commit is contained in:
Alexander Baryshnikov 2020-10-10 17:52:11 +08:00
parent 9c9e79be15
commit b837639f97
4 changed files with 15 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,8 +14,9 @@ type Meta interface {
}
type AttemptHeader struct {
Code int `json:"code"`
Headers http.Header `json:"headers"`
Code int `json:"code"`
Headers http.Header `json:"headers"`
StartedAt time.Time `json:"started_at"`
}
type Attempt struct {

View File

@ -40,8 +40,15 @@
<dl class="row">
<dt class="col-sm-3">ID</dt>
<dd class="col-sm-9">{{.AttemptID}}</dd>
<dt class="col-sm-3">Created at</dt>
<dd class="col-sm-9">{{.Attempt.CreatedAt.Format "02 Jan 06 15:04:05.000 MST"}}</dd>
<dt class="col-sm-3">Started at</dt>
<dd class="col-sm-9">
{{.Attempt.StartedAt.Format "02 Jan 06 15:04:05.000 MST"}}
</dd>
<dt class="col-sm-3">Finished at</dt>
<dd class="col-sm-9">
{{.Attempt.CreatedAt.Format "02 Jan 06 15:04:05.000 MST"}}
<footer class="blockquote-footer">after {{.Attempt.CreatedAt.Sub .Attempt.StartedAt}}</footer>
</dd>
<dt class="col-sm-3">Code</dt>
<dd class="col-sm-9">{{.Attempt.Code}}</dd>
</dl>

View File

@ -301,8 +301,10 @@ func (mgr *Worker) call(ctx context.Context, requestID string, info *meta.Reques
err = mgr.blob.Push(attemptID, func(out io.Writer) error {
res := openResponse(out)
started := time.Now()
mgr.handler.ServeHTTP(res, req)
header = res.meta
header.StartedAt = started
return nil
})
if err != nil {