Skip to content

Commit 85eacf2

Browse files
adrianlztdanielnelson
authored andcommitted
Fix minmax and basicstats aggregators to use uint64 (influxdata#4294)
1 parent 1a781a5 commit 85eacf2

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

plugins/aggregators/basicstats/basicstats.go

+2
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ func convert(in interface{}) (float64, bool) {
246246
return v, true
247247
case int64:
248248
return float64(v), true
249+
case uint64:
250+
return float64(v), true
249251
default:
250252
return 0, false
251253
}

plugins/aggregators/basicstats/basicstats_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var m2, _ = metric.New("m1",
2828
"c": float64(4),
2929
"d": float64(6),
3030
"e": float64(200),
31+
"f": uint64(200),
3132
"ignoreme": "string",
3233
"andme": true,
3334
},
@@ -81,6 +82,10 @@ func TestBasicStatsWithPeriod(t *testing.T) {
8182
"e_max": float64(200),
8283
"e_min": float64(200),
8384
"e_mean": float64(200),
85+
"f_count": float64(1), //f
86+
"f_max": float64(200),
87+
"f_min": float64(200),
88+
"f_mean": float64(200),
8489
}
8590
expectedTags := map[string]string{
8691
"foo": "bar",
@@ -144,6 +149,10 @@ func TestBasicStatsDifferentPeriods(t *testing.T) {
144149
"e_max": float64(200),
145150
"e_min": float64(200),
146151
"e_mean": float64(200),
152+
"f_count": float64(1), //f
153+
"f_max": float64(200),
154+
"f_min": float64(200),
155+
"f_mean": float64(200),
147156
}
148157
expectedTags = map[string]string{
149158
"foo": "bar",
@@ -169,6 +178,7 @@ func TestBasicStatsWithOnlyCount(t *testing.T) {
169178
"c_count": float64(2),
170179
"d_count": float64(2),
171180
"e_count": float64(1),
181+
"f_count": float64(1),
172182
}
173183
expectedTags := map[string]string{
174184
"foo": "bar",
@@ -194,6 +204,7 @@ func TestBasicStatsWithOnlyMin(t *testing.T) {
194204
"c_min": float64(2),
195205
"d_min": float64(2),
196206
"e_min": float64(200),
207+
"f_min": float64(200),
197208
}
198209
expectedTags := map[string]string{
199210
"foo": "bar",
@@ -219,6 +230,7 @@ func TestBasicStatsWithOnlyMax(t *testing.T) {
219230
"c_max": float64(4),
220231
"d_max": float64(6),
221232
"e_max": float64(200),
233+
"f_max": float64(200),
222234
}
223235
expectedTags := map[string]string{
224236
"foo": "bar",
@@ -244,6 +256,7 @@ func TestBasicStatsWithOnlyMean(t *testing.T) {
244256
"c_mean": float64(3),
245257
"d_mean": float64(4),
246258
"e_mean": float64(200),
259+
"f_mean": float64(200),
247260
}
248261
expectedTags := map[string]string{
249262
"foo": "bar",
@@ -269,6 +282,7 @@ func TestBasicStatsWithOnlySum(t *testing.T) {
269282
"c_sum": float64(6),
270283
"d_sum": float64(8),
271284
"e_sum": float64(200),
285+
"f_sum": float64(200),
272286
}
273287
expectedTags := map[string]string{
274288
"foo": "bar",
@@ -399,6 +413,8 @@ func TestBasicStatsWithMinAndMax(t *testing.T) {
399413
"d_min": float64(2),
400414
"e_max": float64(200), //e
401415
"e_min": float64(200),
416+
"f_max": float64(200), //f
417+
"f_min": float64(200),
402418
}
403419
expectedTags := map[string]string{
404420
"foo": "bar",
@@ -450,6 +466,11 @@ func TestBasicStatsWithAllStats(t *testing.T) {
450466
"e_min": float64(200),
451467
"e_mean": float64(200),
452468
"e_sum": float64(200),
469+
"f_count": float64(1), //f
470+
"f_max": float64(200),
471+
"f_min": float64(200),
472+
"f_mean": float64(200),
473+
"f_sum": float64(200),
453474
}
454475
expectedTags := map[string]string{
455476
"foo": "bar",

plugins/aggregators/minmax/minmax.go

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ func convert(in interface{}) (float64, bool) {
107107
return v, true
108108
case int64:
109109
return float64(v), true
110+
case uint64:
111+
return float64(v), true
110112
default:
111113
return 0, false
112114
}

plugins/aggregators/minmax/minmax_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var m2, _ = metric.New("m1",
3838
"i": float64(1),
3939
"j": float64(1),
4040
"k": float64(200),
41+
"l": uint64(200),
4142
"ignoreme": "string",
4243
"andme": true,
4344
},
@@ -85,6 +86,8 @@ func TestMinMaxWithPeriod(t *testing.T) {
8586
"j_min": float64(1),
8687
"k_max": float64(200),
8788
"k_min": float64(200),
89+
"l_max": float64(200),
90+
"l_min": float64(200),
8891
}
8992
expectedTags := map[string]string{
9093
"foo": "bar",
@@ -154,6 +157,8 @@ func TestMinMaxDifferentPeriods(t *testing.T) {
154157
"j_min": float64(1),
155158
"k_max": float64(200),
156159
"k_min": float64(200),
160+
"l_max": float64(200),
161+
"l_min": float64(200),
157162
}
158163
expectedTags = map[string]string{
159164
"foo": "bar",

0 commit comments

Comments
 (0)