Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add latency graph command #2359

Merged
merged 5 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/client/lib/client/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ import * as HELLO from '../commands/HELLO';
import * as INFO from '../commands/INFO';
import * as KEYS from '../commands/KEYS';
import * as LASTSAVE from '../commands/LASTSAVE';
import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';
import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH';
import * as LOLWUT from '../commands/LOLWUT';
import * as MEMORY_DOCTOR from '../commands/MEMORY_DOCTOR';
import * as MEMORY_MALLOC_STATS from '../commands/MEMORY_MALLOC-STATS';
Expand Down Expand Up @@ -113,7 +115,6 @@ import * as SWAPDB from '../commands/SWAPDB';
import * as TIME from '../commands/TIME';
import * as UNWATCH from '../commands/UNWATCH';
import * as WAIT from '../commands/WAIT';
import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';

export default {
...CLUSTER_COMMANDS,
Expand Down Expand Up @@ -283,6 +284,8 @@ export default {
lastSave: LASTSAVE,
LATENCY_DOCTOR,
latencyDoctor: LATENCY_DOCTOR,
LATENCY_GRAPH,
latencyGraph: LATENCY_GRAPH,
LOLWUT,
lolwut: LOLWUT,
MEMORY_DOCTOR,
Expand Down
30 changes: 30 additions & 0 deletions packages/client/lib/commands/LATENCY_GRAPH.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { strict as assert } from 'assert';
import testUtils from '../test-utils';
import { transformArguments } from './LATENCY_GRAPH';

describe('LATENCY GRAPH', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('command'),
[
'LATENCY',
'GRAPH',
'command'
]
);
});

testUtils.testWithClient('client.latencyGraph', async (client) => {
await Promise.all([
client.configSet('latency-monitor-threshold', '1'),
client.sendCommand(['DEBUG', 'SLEEP', '.1'])
]);

assert.equal(
typeof await client.latencyGraph('command'),
'string'
);
}, {
serverArguments: ['--enable-debug-command', 'yes']
K4ST0R marked this conversation as resolved.
Show resolved Hide resolved
});
});
25 changes: 25 additions & 0 deletions packages/client/lib/commands/LATENCY_GRAPH.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { RedisCommandArguments } from '.';

export type EventType =
'active-defrag-cycle'
| 'aof-fsync-always'
| 'aof-stat'
| 'aof-rewrite-diff-write'
| 'aof-rename'
| 'aof-write'
| 'aof-write-active-child'
| 'aof-write-alone'
| 'aof-write-pending-fsync'
| 'command'
| 'expire-cycle'
| 'eviction-cycle'
| 'eviction-del'
| 'fast-command'
| 'fork'
| 'rdb-unlink-temp-file';

export function transformArguments(event: EventType): RedisCommandArguments {
return ['LATENCY', 'GRAPH', event];
}

export declare function transformReply(): string;