192 | 192 |
if err := svc.testDimensions(n99, label, value); err != nil {
|
193 | 193 |
t.Fatal(err)
|
194 | 194 |
}
|
195 | |
}
|
|
195 |
|
|
196 |
// now test with only 2 custom percentiles
|
|
197 |
//
|
|
198 |
svc = newMockCloudWatch()
|
|
199 |
cw = New(namespace, svc, WithLogger(log.NewNopLogger()), WithPercentiles(0.50, 0.90))
|
|
200 |
histogram = cw.NewHistogram(name).With(label, value)
|
|
201 |
|
|
202 |
customQuantiles := func() (p50, p90, p95, p99 float64) {
|
|
203 |
err := cw.Send()
|
|
204 |
if err != nil {
|
|
205 |
t.Fatal(err)
|
|
206 |
}
|
|
207 |
svc.mtx.RLock()
|
|
208 |
defer svc.mtx.RUnlock()
|
|
209 |
p50 = svc.valuesReceived[n50]
|
|
210 |
p90 = svc.valuesReceived[n90]
|
|
211 |
|
|
212 |
// our teststat.TestHistogram wants us to give p95 and p99,
|
|
213 |
// but with custom percentiles we don't have those.
|
|
214 |
// So fake them. Maybe we should make teststat.nvq() public and use that?
|
|
215 |
p95 = 541.121341
|
|
216 |
p99 = 558.158697
|
|
217 |
|
|
218 |
// but fail if they are actually set (because that would mean the
|
|
219 |
// WithPercentiles() is not respected)
|
|
220 |
if _, isSet := svc.valuesReceived[n95]; isSet {
|
|
221 |
t.Fatal("p95 should not be set")
|
|
222 |
}
|
|
223 |
if _, isSet := svc.valuesReceived[n99]; isSet {
|
|
224 |
t.Fatal("p99 should not be set")
|
|
225 |
}
|
|
226 |
return
|
|
227 |
}
|
|
228 |
if err := teststat.TestHistogram(histogram, customQuantiles, 0.01); err != nil {
|
|
229 |
t.Fatal(err)
|
|
230 |
}
|
|
231 |
if err := svc.testDimensions(n50, label, value); err != nil {
|
|
232 |
t.Fatal(err)
|
|
233 |
}
|
|
234 |
if err := svc.testDimensions(n90, label, value); err != nil {
|
|
235 |
t.Fatal(err)
|
|
236 |
}
|
|
237 |
if err := svc.testDimensions(n95, label, value); err != nil {
|
|
238 |
t.Fatal(err)
|
|
239 |
}
|
|
240 |
if err := svc.testDimensions(n99, label, value); err != nil {
|
|
241 |
t.Fatal(err)
|
|
242 |
}
|
|
243 |
}
|