summaryrefslogtreecommitdiff
path: root/src/latency.c
diff options
context:
space:
mode:
authorzhaozhao.zz <276441700@qq.com>2022-01-17 18:32:32 +0800
committerGitHub <noreply@github.com>2022-01-17 12:32:32 +0200
commit90916f16a5536bc833529d2e563d1094433de495 (patch)
tree8ddc2049cc3a332273d1d982e9281fb5a30c7ca5 /src/latency.c
parent26ef5132a6d8866639b9a2bfb27e631e51aa5c2f (diff)
downloadredis-90916f16a5536bc833529d2e563d1094433de495.tar.gz
show subcommands latencystats (#10103)
since `info commandstats` already shows sub-commands, we should do the same in `info latencystats`. similarly, the LATENCY HISTOGRAM command now shows sub-commands (with their full name) when: * asking for all commands * asking for a specific container command * asking for a specific sub-command) Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/latency.c')
-rw-r--r--src/latency.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/latency.c b/src/latency.c
index ff8d66069..1eac48191 100644
--- a/src/latency.c
+++ b/src/latency.c
@@ -530,11 +530,22 @@ void latencyAllCommandsFillCDF(client *c) {
int command_with_data = 0;
while((de = dictNext(di)) != NULL) {
cmd = (struct redisCommand *) dictGetVal(de);
- if (!cmd->latency_histogram)
- continue;
- addReplyBulkCString(c,cmd->name);
- fillCommandCDF(c, cmd->latency_histogram);
- command_with_data++;
+ if (cmd->latency_histogram) {
+ addReplyBulkCString(c,cmd->name);
+ fillCommandCDF(c, cmd->latency_histogram);
+ command_with_data++;
+ }
+
+ if (cmd->subcommands) {
+ for (int j = 0; cmd->subcommands[j].name; j++) {
+ struct redisCommand *sub = cmd->subcommands+j;
+ if (sub->latency_histogram) {
+ addReplyBulkSds(c,getFullCommandName(sub));
+ fillCommandCDF(c, sub->latency_histogram);
+ command_with_data++;
+ }
+ }
+ }
}
dictReleaseIterator(di);
setDeferredMapLen(c,replylen,command_with_data);
@@ -546,18 +557,28 @@ void latencySpecificCommandsFillCDF(client *c) {
void *replylen = addReplyDeferredLen(c);
int command_with_data = 0;
for (int j = 2; j < c->argc; j++){
- struct redisCommand *cmd = dictFetchValue(server.commands, c->argv[j]->ptr);
+ struct redisCommand *cmd = lookupCommandBySds(c->argv[j]->ptr);
/* If the command does not exist we skip the reply */
if (cmd == NULL) {
continue;
}
- /* If no latency info we reply with the same format as non empty histograms */
- if (!cmd->latency_histogram) {
- continue;
+
+ if (cmd->latency_histogram) {
+ addReplyBulkSds(c,getFullCommandName(cmd));
+ fillCommandCDF(c, cmd->latency_histogram);
+ command_with_data++;
+ }
+
+ if (cmd->subcommands) {
+ for (int j = 0; cmd->subcommands[j].name; j++) {
+ struct redisCommand *sub = cmd->subcommands+j;
+ if (sub->latency_histogram) {
+ addReplyBulkSds(c,getFullCommandName(sub));
+ fillCommandCDF(c, sub->latency_histogram);
+ command_with_data++;
+ }
+ }
}
- addReplyBulkCString(c,c->argv[j]->ptr);
- fillCommandCDF(c, cmd->latency_histogram);
- command_with_data++;
}
setDeferredMapLen(c,replylen,command_with_data);
}