File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ import * as KEYS from '../commands/KEYS';
8686import * as LASTSAVE from '../commands/LASTSAVE' ;
8787import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR' ;
8888import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH' ;
89+ import * as LATENCY_HISTORY from '../commands/LATENCY_HISTORY' ;
8990import * as LATENCY_LATEST from '../commands/LATENCY_LATEST' ;
9091import * as LOLWUT from '../commands/LOLWUT' ;
9192import * as MEMORY_DOCTOR from '../commands/MEMORY_DOCTOR' ;
@@ -298,6 +299,8 @@ export default {
298299 latencyDoctor : LATENCY_DOCTOR ,
299300 LATENCY_GRAPH ,
300301 latencyGraph : LATENCY_GRAPH ,
302+ LATENCY_HISTORY ,
303+ latencyHistory : LATENCY_HISTORY ,
301304 LATENCY_LATEST ,
302305 latencyLatest : LATENCY_LATEST ,
303306 LOLWUT ,
Original file line number Diff line number Diff line change 1+ import { strict as assert } from 'assert' ;
2+ import testUtils , { GLOBAL } from '../test-utils' ;
3+ import { transformArguments } from './LATENCY_HISTORY' ;
4+
5+ describe ( 'LATENCY HISTORY' , ( ) => {
6+ it ( 'transformArguments' , ( ) => {
7+ assert . deepEqual (
8+ transformArguments ( 'command' ) ,
9+ [ 'LATENCY' , 'HISTORY' , 'command' ]
10+ ) ;
11+ } ) ;
12+
13+ testUtils . testWithClient ( 'client.latencyHistory' , async client => {
14+ await Promise . all ( [
15+ client . configSet ( 'latency-monitor-threshold' , '100' ) ,
16+ client . sendCommand ( [ 'DEBUG' , 'SLEEP' , '1' ] )
17+ ] ) ;
18+
19+ const latencyHisRes = await client . latencyHistory ( 'command' ) ;
20+ assert . ok ( Array . isArray ( latencyHisRes ) ) ;
21+ for ( const [ timestamp , latency ] of latencyHisRes ) {
22+ assert . equal ( typeof timestamp , 'number' ) ;
23+ assert . equal ( typeof latency , 'number' ) ;
24+ }
25+ } , GLOBAL . SERVERS . OPEN ) ;
26+ } ) ;
Original file line number Diff line number Diff line change 1+ export type EventType = (
2+ 'active-defrag-cycle' |
3+ 'aof-fsync-always' |
4+ 'aof-stat' |
5+ 'aof-rewrite-diff-write' |
6+ 'aof-rename' |
7+ 'aof-write' |
8+ 'aof-write-active-child' |
9+ 'aof-write-alone' |
10+ 'aof-write-pending-fsync' |
11+ 'command' |
12+ 'expire-cycle' |
13+ 'eviction-cycle' |
14+ 'eviction-del' |
15+ 'fast-command' |
16+ 'fork' |
17+ 'rdb-unlink-temp-file'
18+ ) ;
19+
20+ export function transformArguments ( event : EventType ) {
21+ return [ 'LATENCY' , 'HISTORY' , event ] ;
22+ }
23+
24+ export declare function transformReply ( ) : Array < [
25+ timestamp : number ,
26+ latency : number ,
27+ ] > ;
You can’t perform that action at this time.
0 commit comments