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

Ttfb should not be negative #56

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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