@@ -38,10 +38,10 @@ def redis_slowlog(index, time, microseconds, command='eval')
38
38
allow ( redis ) . to receive ( :connection ) { { host : 'master.replicationgroup.abcde.use2.cache.amazonaws.com' } }
39
39
allow ( redis ) . to receive ( :slowlog ) . with ( 'get' , 128 ) {
40
40
[
41
- redis_slowlog ( 3 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 45 ) , 400000 ) ,
42
- redis_slowlog ( 2 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 15 ) , 100000 ) ,
43
- redis_slowlog ( 1 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 45 ) , 100000 ) ,
44
- redis_slowlog ( 0 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 15 ) , 200000 ) ,
41
+ redis_slowlog ( 3 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 45 ) , 400000 ) ,
42
+ redis_slowlog ( 2 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 15 ) , 100000 ) ,
43
+ redis_slowlog ( 1 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 45 ) , 100000 ) ,
44
+ redis_slowlog ( 0 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 15 ) , 200000 ) ,
45
45
]
46
46
}
47
47
@@ -52,37 +52,37 @@ def redis_slowlog(index, time, microseconds, command='eval')
52
52
Time . now - 7200 ,
53
53
Time . now
54
54
) {
55
- [
56
- "200" ,
57
- {
58
- "status" => "ok" ,
59
- "res_type" => "time_series" ,
60
- "series" =>
61
- [
62
- {
63
- "end" => 1587684599000 ,
64
- "attributes" => { } ,
65
- "metric" => "rspec.redis.slowlog.micros.95percentile" ,
66
- "interval" => 300 ,
67
- "tag_set" => [ ] ,
68
- "start" => 1587602100000 ,
69
- "length" => 3 ,
70
- "query_index" => 0 ,
71
- "aggr" => nil ,
72
- "scope" => "replication_group:replicationgroup" ,
73
- "pointlist" => [ [ four_minutes_ago , 99994.0 ] , [ four_minutes_ago - 5000 , 99378.0 ] ] ,
74
- "expression" => "rspec.redis.slowlog.micros.95percentile{replication_group:infraeng-dev-redis}" ,
75
- "unit" => nil ,
76
- "display_name" => "rspec.redis.slowlog.micros.95percentile"
77
- }
78
- ] ,
79
- "resp_version" => 1 ,
80
- "query" => "rspec.redis.slowlog.micros.95percentile{replication_group:replicationgroup}" ,
81
- "message" => "" ,
82
- "group_by" => [ ]
83
- }
84
- ]
85
- }
55
+ [
56
+ "200" ,
57
+ {
58
+ "status" => "ok" ,
59
+ "res_type" => "time_series" ,
60
+ "series" =>
61
+ [
62
+ {
63
+ "end" => 1587684599000 ,
64
+ "attributes" => { } ,
65
+ "metric" => "rspec.redis.slowlog.micros.95percentile" ,
66
+ "interval" => 300 ,
67
+ "tag_set" => [ ] ,
68
+ "start" => 1587602100000 ,
69
+ "length" => 3 ,
70
+ "query_index" => 0 ,
71
+ "aggr" => nil ,
72
+ "scope" => "replication_group:replicationgroup" ,
73
+ "pointlist" => [ [ four_minutes_ago , 99994.0 ] , [ four_minutes_ago - 5000 , 99378.0 ] ] ,
74
+ "expression" => "rspec.redis.slowlog.micros.95percentile{replication_group:infraeng-dev-redis}" ,
75
+ "unit" => nil ,
76
+ "display_name" => "rspec.redis.slowlog.micros.95percentile"
77
+ }
78
+ ] ,
79
+ "resp_version" => 1 ,
80
+ "query" => "rspec.redis.slowlog.micros.95percentile{replication_group:replicationgroup}" ,
81
+ "message" => "" ,
82
+ "group_by" => [ ]
83
+ }
84
+ ]
85
+ }
86
86
87
87
# Freeze time
88
88
Timecop . freeze ( frozen_time )
@@ -96,10 +96,10 @@ def redis_slowlog(index, time, microseconds, command='eval')
96
96
before ( :each ) do
97
97
allow ( redis ) . to receive ( :slowlog ) . with ( 'get' , 128 ) {
98
98
[
99
- redis_slowlog ( 3 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 45 ) , 400000 ) ,
100
- redis_slowlog ( 2 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 15 ) , 100000 ) ,
101
- redis_slowlog ( 1 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 45 ) , 100000 ) ,
102
- redis_slowlog ( 0 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 15 ) , 200000 ) ,
99
+ redis_slowlog ( 3 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 45 ) , 400000 ) ,
100
+ redis_slowlog ( 2 , Time . utc ( 2020 , 4 , 20 , 4 , 19 , 15 ) , 100000 ) ,
101
+ redis_slowlog ( 1 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 45 ) , 100000 ) ,
102
+ redis_slowlog ( 0 , Time . utc ( 2020 , 4 , 20 , 4 , 18 , 15 ) , 200000 ) ,
103
103
]
104
104
}
105
105
end
@@ -130,10 +130,10 @@ def redis_slowlog(index, time, microseconds, command='eval')
130
130
131
131
context 'redis has 1048576 * 2 + 1 entries and a zeroeth entry' do
132
132
let ( :sauce ) {
133
- Array . new ( 1048576 * 2 + 1 ) { |x |
134
- redis_slowlog ( x , 1587352800 , x ) #lettuce not create so many unnecessary Time objects
135
- } . reverse
136
- }
133
+ Array . new ( 1048576 * 2 + 1 ) { |x |
134
+ redis_slowlog ( x , 1587352800 , x ) #lettuce not create so many unnecessary Time objects
135
+ } . reverse
136
+ }
137
137
before ( :each ) do
138
138
allow ( redis ) . to receive ( :slowlog ) { |_ , number |
139
139
sauce [ 0 ..number -1 ]
@@ -146,10 +146,10 @@ def redis_slowlog(index, time, microseconds, command='eval')
146
146
147
147
context 'redis has 567 entries and no zeroeth entry' do
148
148
let ( :sauce ) {
149
- Array . new ( 567 ) { |x |
150
- redis_slowlog ( x + 1 , Time . utc ( 2020 , 4 , 20 , 3 , 20 , 0 ) + x , x )
151
- } . reverse
152
- }
149
+ Array . new ( 567 ) { |x |
150
+ redis_slowlog ( x + 1 , Time . utc ( 2020 , 4 , 20 , 3 , 20 , 0 ) + x , x )
151
+ } . reverse
152
+ }
153
153
before ( :each ) do
154
154
allow ( redis ) . to receive ( :slowlog ) { |_ , number |
155
155
sauce [ 0 ..number -1 ]
@@ -219,10 +219,10 @@ def redis_slowlog(index, time, microseconds, command='eval')
219
219
subject { slowlog_check . reporting_interval }
220
220
focus 'generates an array at minute intervals' do
221
221
expect ( subject ) . to eq (
222
- Time . utc ( 2020 , 4 , 20 , 4 , 19 ) . localtime => { } ,
223
- Time . utc ( 2020 , 4 , 20 , 4 , 18 ) . localtime => { } ,
224
- Time . utc ( 2020 , 4 , 20 , 4 , 17 ) . localtime => { } ,
225
- )
222
+ Time . utc ( 2020 , 4 , 20 , 4 , 19 ) . localtime => { } ,
223
+ Time . utc ( 2020 , 4 , 20 , 4 , 18 ) . localtime => { } ,
224
+ Time . utc ( 2020 , 4 , 20 , 4 , 17 ) . localtime => { } ,
225
+ )
226
226
end
227
227
end
228
228
@@ -266,54 +266,55 @@ def redis_slowlog(index, time, microseconds, command='eval')
266
266
let ( :bucket18 ) {
267
267
{
268
268
"eval" =>
269
- {
270
- _95percentile : 100000 ,
271
- avg : 150000 ,
272
- count : 2 ,
273
- max : 200000 ,
274
- median : 100000 ,
275
- min : 100000 ,
276
- sum : 300000 ,
277
- values : [ 100000 , 200000 ]
278
- }
269
+ {
270
+ _95percentile : 100000 ,
271
+ avg : 150000 ,
272
+ count : 2 ,
273
+ max : 200000 ,
274
+ median : 100000 ,
275
+ min : 100000 ,
276
+ sum : 300000 ,
277
+ values : [ 100000 , 200000 ]
278
+ }
279
279
}
280
280
}
281
281
let ( :bucket19 ) {
282
282
{
283
283
"eval" =>
284
- {
285
- _95percentile : 100000 ,
286
- avg : 250000 ,
287
- count : 2 ,
288
- max : 400000 ,
289
- median : 100000 ,
290
- min : 100000 ,
291
- sum : 500000 ,
292
- values : [ 400000 , 100000 ]
293
- }
284
+ {
285
+ _95percentile : 100000 ,
286
+ avg : 250000 ,
287
+ count : 2 ,
288
+ max : 400000 ,
289
+ median : 100000 ,
290
+ min : 100000 ,
291
+ sum : 500000 ,
292
+ values : [ 400000 , 100000 ]
293
+ }
294
294
}
295
295
}
296
+
296
297
it { is_expected . to eq (
297
- {
298
- Time . utc ( 2020 , 4 , 20 , 4 , 17 ) . localtime => { } ,
299
- Time . utc ( 2020 , 4 , 20 , 4 , 18 ) . localtime => bucket18 ,
300
- Time . utc ( 2020 , 4 , 20 , 4 , 19 ) . localtime => bucket19 ,
301
- }
302
- )
298
+ {
299
+ Time . utc ( 2020 , 4 , 20 , 4 , 17 ) . localtime => { } ,
300
+ Time . utc ( 2020 , 4 , 20 , 4 , 18 ) . localtime => bucket18 ,
301
+ Time . utc ( 2020 , 4 , 20 , 4 , 19 ) . localtime => bucket19 ,
302
+ }
303
+ )
303
304
}
304
305
end
305
306
306
307
describe '#default_tags' do
307
308
subject { slowlog_check . default_tags }
308
309
it { is_expected . to eq (
309
- {
310
- aws : 'true' ,
311
- env : 'test' ,
312
- namespace : 'rspec' ,
313
- replication_group : 'replicationgroup' ,
314
- service : 'replicationgroup' ,
315
- }
316
- )
310
+ {
311
+ aws : 'true' ,
312
+ env : 'test' ,
313
+ namespace : 'rspec' ,
314
+ replication_group : 'replicationgroup' ,
315
+ service : 'replicationgroup' ,
316
+ }
317
+ )
317
318
}
318
319
end
319
320
@@ -325,14 +326,14 @@ def redis_slowlog(index, time, microseconds, command='eval')
325
326
:interval => 60 ,
326
327
:type => "gauge" ,
327
328
:tags =>
328
- {
329
- :aws => "true" ,
330
- :command => "eval" ,
331
- :env => "test" ,
332
- :namespace => "rspec" ,
333
- :replication_group => "replicationgroup" ,
334
- :service => "replicationgroup"
335
- }
329
+ {
330
+ :aws => "true" ,
331
+ :command => "eval" ,
332
+ :env => "test" ,
333
+ :namespace => "rspec" ,
334
+ :replication_group => "replicationgroup" ,
335
+ :service => "replicationgroup"
336
+ }
336
337
}
337
338
}
338
339
@@ -360,22 +361,22 @@ def redis_slowlog(index, time, microseconds, command='eval')
360
361
metric = name . split ( '.' ) . last
361
362
[ "200" ,
362
363
{
363
- "description" => "slowlog duration #{ metric } (µs)" ,
364
- "short_name" => "#{ metric } (µs)" ,
365
- "integration" => nil ,
366
- "statsd_interval" => 60 ,
367
- "per_unit" => nil ,
368
- "type" => "gauge" ,
369
- "unit" => "microsecond"
370
- }
364
+ "description" => "slowlog duration #{ metric } (µs)" ,
365
+ "short_name" => "#{ metric } (µs)" ,
366
+ "integration" => nil ,
367
+ "statsd_interval" => 60 ,
368
+ "per_unit" => nil ,
369
+ "type" => "gauge" ,
370
+ "unit" => "microsecond"
371
+ }
371
372
]
372
373
}
373
374
}
374
375
375
376
describe '#diff_metadatas' do
376
377
subject { slowlog_check . diff_metadatas }
377
378
let ( :diff ) {
378
- {
379
+ {
379
380
"name" => "rspec.redis.slowlog.micros.count" ,
380
381
"description" => "slowlog entries per minute" ,
381
382
"short_name" => "per minute" ,
@@ -407,8 +408,8 @@ def redis_slowlog(index, time, microseconds, command='eval')
407
408
subject
408
409
409
410
expect ( ddog ) . to have_received ( :update_metadata ) . with (
410
- 'rspec.redis.slowlog.micros.count' ,
411
- diff
411
+ 'rspec.redis.slowlog.micros.count' ,
412
+ diff
412
413
)
413
414
end
414
415
end
0 commit comments