File: 0002-fix-inmem-ratedenom.patch

package info (click to toggle)
golang-github-armon-go-metrics 0.0~git20160307.0.f303b03-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch, stretch-backports
  • size: 172 kB
  • ctags: 191
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Revert commit b79a89c to fix tests
 The code cleanup commit in b79a89c breaks the unit tests. In particular 
 rateDenom becomes zero if nanoseconds are not used for the calculation 
 causing the Rate to become +Inf.
Author: Tim Potter <tpot@hpe.com>
Bug: https://github.com/armon/go-metrics/pull/29
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: golang-github-armon-go-metrics/inmem.go
===================================================================
--- golang-github-armon-go-metrics.orig/inmem.go
+++ golang-github-armon-go-metrics/inmem.go
@@ -123,11 +123,12 @@ func (a *AggregateSample) String() strin
 // NewInmemSink is used to construct a new in-memory sink.
 // Uses an aggregation interval and maximum retention period.
 func NewInmemSink(interval, retain time.Duration) *InmemSink {
+	rateTimeUnit := time.Second
 	i := &InmemSink{
 		interval:     interval,
 		retain:       retain,
 		maxIntervals: int(retain / interval),
-		rateDenom: float64(interval / time.Second),
+		rateDenom: float64(interval.Nanoseconds()) / float64(rateTimeUnit.Nanoseconds()),
 	}
 	i.intervals = make([]*IntervalMetrics, 0, i.maxIntervals)
 	return i