diff --git a/CHANGELOG.md b/CHANGELOG.md index 46428ca95..c9ebcc2c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,13 @@ The following emojis are used to highlight certain changes: ### Security +## [v0.27.3] + +### Added + +- `provider`: Added `ReprovideInterval` and `LastRun` stats to the Reprovider [#815](https://github.com/ipfs/boxo/pull/815) + + ## [v0.27.2] ### Fixed diff --git a/provider/reprovider.go b/provider/reprovider.go index 2959b64b8..aeb5a27a5 100644 --- a/provider/reprovider.go +++ b/provider/reprovider.go @@ -62,6 +62,7 @@ type reprovider struct { statLk sync.Mutex totalProvides, lastReprovideBatchSize uint64 avgProvideDuration, lastReprovideDuration time.Duration + lastRun time.Time throughputCallback ThroughputCallback // throughputProvideCurrentCount counts how many provides has been done since the last call to throughputCallback @@ -363,6 +364,7 @@ func (s *reprovider) run() { if performedReprovide { s.lastReprovideBatchSize = uint64(len(keys)) s.lastReprovideDuration = dur + s.lastRun = time.Now() s.statLk.Unlock() @@ -537,8 +539,9 @@ func (s *reprovider) shouldReprovide() bool { } type ReproviderStats struct { - TotalProvides, LastReprovideBatchSize uint64 - AvgProvideDuration, LastReprovideDuration time.Duration + TotalProvides, LastReprovideBatchSize uint64 + ReprovideInterval, AvgProvideDuration, LastReprovideDuration time.Duration + LastRun time.Time } // Stat returns various stats about this provider system @@ -548,8 +551,10 @@ func (s *reprovider) Stat() (ReproviderStats, error) { return ReproviderStats{ TotalProvides: s.totalProvides, LastReprovideBatchSize: s.lastReprovideBatchSize, + ReprovideInterval: s.reprovideInterval, AvgProvideDuration: s.avgProvideDuration, LastReprovideDuration: s.lastReprovideDuration, + LastRun: s.lastRun, }, nil }