Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
a57eb327
Commit
a57eb327
authored
Jul 01, 2014
by
antirez
Browse files
LATENCY SAMPLES implemented.
parent
72c84acc
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/latency.c
View file @
a57eb327
...
...
@@ -89,5 +89,49 @@ void latencyAddSample(char *event, mstime_t latency) {
/* ---------------------- Latency command implementation -------------------- */
/* latencyCommand() helper to produce a time-delay reply for all the samples
* in memory for the specified time series. */
void
latencyCommandReplyWithSamples
(
redisClient
*
c
,
struct
latencyTimeSeries
*
ts
)
{
void
*
replylen
=
addDeferredMultiBulkLength
(
c
);
int
samples
=
0
,
j
;
for
(
j
=
0
;
j
<
LATENCY_TS_LEN
;
j
++
)
{
int
i
=
(
ts
->
idx
+
j
)
%
LATENCY_TS_LEN
;
if
(
ts
->
samples
[
i
].
time
==
0
)
continue
;
addReplyMultiBulkLen
(
c
,
2
);
addReplyLongLong
(
c
,
ts
->
samples
[
i
].
time
);
addReplyLongLong
(
c
,
ts
->
samples
[
i
].
latency
);
samples
++
;
}
setDeferredMultiBulkLength
(
c
,
replylen
,
samples
);
}
/* LATENCY command implementations.
*
* LATENCY SAMPLES: return time-latency samples for the specified event.
* LATENCY LATEST: return the latest latency for all the events classes.
* LATENCY DOCTOR: returns an human readable analysis of instance latency.
* LATENCY GRAPH: provide an ASCII graph of the latency of the specified event.
*/
void
latencyCommand
(
redisClient
*
c
)
{
struct
latencyTimeSeries
*
ts
;
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"samples"
)
&&
c
->
argc
==
3
)
{
/* LATENCY SAMPLES <event> */
ts
=
dictFetchValue
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
if
(
ts
==
NULL
)
goto
nodataerr
;
latencyCommandReplyWithSamples
(
c
,
ts
);
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
return
;
}
return
;
nodataerr:
/* Common error when the user asks for an event we have no latency
* information about. */
addReplyErrorFormat
(
c
,
"No samples available for event '%s'"
,
c
->
argv
[
2
]
->
ptr
);
}
src/redis.c
View file @
a57eb327
...
...
@@ -273,7 +273,8 @@ struct redisCommand redisCommandTable[] = {
{
"pfadd"
,
pfaddCommand
,
-
2
,
"wmF"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"pfcount"
,
pfcountCommand
,
-
2
,
"w"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"pfmerge"
,
pfmergeCommand
,
-
2
,
"wm"
,
0
,
NULL
,
1
,
-
1
,
1
,
0
,
0
},
{
"pfdebug"
,
pfdebugCommand
,
-
3
,
"w"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
}
{
"pfdebug"
,
pfdebugCommand
,
-
3
,
"w"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"latency"
,
latencyCommand
,
-
2
,
"arslt"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
}
};
/*============================ Utility functions ============================ */
...
...
src/redis.h
View file @
a57eb327
...
...
@@ -1388,6 +1388,7 @@ void pfaddCommand(redisClient *c);
void
pfcountCommand
(
redisClient
*
c
);
void
pfmergeCommand
(
redisClient
*
c
);
void
pfdebugCommand
(
redisClient
*
c
);
void
latencyCommand
(
redisClient
*
c
);
#if defined(__GNUC__)
void
*
calloc
(
size_t
count
,
size_t
size
)
__attribute__
((
deprecated
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment