summaryrefslogtreecommitdiff
path: root/src/module.c
diff options
context:
space:
mode:
authorfilipe oliveira <filipecosta.90@gmail.com>2020-12-31 14:53:43 +0000
committerGitHub <noreply@github.com>2020-12-31 16:53:43 +0200
commit90b9f08e5d1657e7bfffe43f31f6663bf469ee75 (patch)
treebc251050eb3eefaa0aecea9ca9e8f61b11ea74df /src/module.c
parent1f5a73a530915f6f6326047effc796218af22cf6 (diff)
downloadredis-90b9f08e5d1657e7bfffe43f31f6663bf469ee75.tar.gz
Add errorstats info section, Add failed_calls and rejected_calls to commandstats (#8217)
This Commit pushes forward the observability on overall error statistics and command statistics within redis-server: It extends INFO COMMANDSTATS to have - failed_calls in - so we can keep track of errors that happen from the command itself, broken by command. - rejected_calls - so we can keep track of errors that were triggered outside the commmand processing per se Adds a new section to INFO, named ERRORSTATS that enables keeping track of the different errors that occur within redis ( within processCommand and call ) based on the reply Error Prefix ( The first word after the "-", up to the first space ). This commit also fixes RM_ReplyWithError so that it can be correctly identified as an error reply.
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/module.c b/src/module.c
index 11f5f4489..913b4de5d 100644
--- a/src/module.c
+++ b/src/module.c
@@ -1368,18 +1368,6 @@ int RM_ReplyWithLongLong(RedisModuleCtx *ctx, long long ll) {
return REDISMODULE_OK;
}
-/* Reply with an error or simple string (status message). Used to implement
- * ReplyWithSimpleString() and ReplyWithError().
- * The function always returns REDISMODULE_OK. */
-int replyWithStatus(RedisModuleCtx *ctx, const char *msg, char *prefix) {
- client *c = moduleGetReplyClient(ctx);
- if (c == NULL) return REDISMODULE_OK;
- addReplyProto(c,prefix,strlen(prefix));
- addReplyProto(c,msg,strlen(msg));
- addReplyProto(c,"\r\n",2);
- return REDISMODULE_OK;
-}
-
/* Reply with the error 'err'.
*
* Note that 'err' must contain all the error, including
@@ -1395,7 +1383,10 @@ int replyWithStatus(RedisModuleCtx *ctx, const char *msg, char *prefix) {
* The function always returns REDISMODULE_OK.
*/
int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) {
- return replyWithStatus(ctx,err,"-");
+ client *c = moduleGetReplyClient(ctx);
+ if (c == NULL) return REDISMODULE_OK;
+ addReplyErrorFormat(c,"-%s",err);
+ return REDISMODULE_OK;
}
/* Reply with a simple string (+... \r\n in RESP protocol). This replies
@@ -1404,7 +1395,12 @@ int RM_ReplyWithError(RedisModuleCtx *ctx, const char *err) {
*
* The function always returns REDISMODULE_OK. */
int RM_ReplyWithSimpleString(RedisModuleCtx *ctx, const char *msg) {
- return replyWithStatus(ctx,msg,"+");
+ client *c = moduleGetReplyClient(ctx);
+ if (c == NULL) return REDISMODULE_OK;
+ addReplyProto(c,"+",1);
+ addReplyProto(c,msg,strlen(msg));
+ addReplyProto(c,"\r\n",2);
+ return REDISMODULE_OK;
}
/* Reply with an array type of 'len' elements. However 'len' other calls