Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #56 from filecoin-saturn/fix/negative--ttfbms
Browse files Browse the repository at this point in the history
Ttfb should not be negative
  • Loading branch information
lidel authored Feb 28, 2023
2 parents cea9966 + fa8b34a commit f4deeda
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,14 @@ func (p *pool) doFetch(ctx context.Context, from string, c cid.Cid, attempt int)
networkError := ""

defer func() {
ttfbMs := fb.Sub(start).Milliseconds()
var ttfbMs int64
durationSecs := time.Since(start).Seconds()
durationMs := time.Since(start).Milliseconds()
goLogger.Debugw("fetch result", "from", from, "of", c, "status", code, "size", received, "ttfb", int(ttfbMs), "duration", durationSecs, "attempt", attempt, "error", e)
fetchResponseMetric.WithLabelValues(fmt.Sprintf("%d", code)).Add(1)

if e == nil && received > 0 {
ttfbMs = fb.Sub(start).Milliseconds()
fetchTTFBPerBlockPerPeerSuccessMetric.Observe(float64(ttfbMs))
fetchDurationPerBlockPerPeerSuccessMetric.Observe(float64(response_success_end.Sub(start).Milliseconds()))
fetchSpeedPerBlockPerPeerMetric.Observe(float64(received) / float64(durationMs))
Expand Down

0 comments on commit f4deeda

Please sign in to comment.