MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / latencyCommandReplyWithLatestEvents

Function latencyCommandReplyWithLatestEvents

src/latency.cpp:513–531  ·  view source on GitHub ↗

latencyCommand() helper to produce the reply for the LATEST subcommand, * listing the last latency sample for every event type registered so far. */

Source from the content-addressed store, hash-verified

511/* latencyCommand() helper to produce the reply for the LATEST subcommand,
512 * listing the last latency sample for every event type registered so far. */
513void latencyCommandReplyWithLatestEvents(client *c) {
514 dictIterator *di;
515 dictEntry *de;
516
517 addReplyArrayLen(c,dictSize(g_pserver->latency_events));
518 di = dictGetIterator(g_pserver->latency_events);
519 while((de = dictNext(di)) != NULL) {
520 char *event = (char*)dictGetKey(de);
521 struct latencyTimeSeries *ts = (latencyTimeSeries*)dictGetVal(de);
522 int last = (ts->idx + LATENCY_TS_LEN - 1) % LATENCY_TS_LEN;
523
524 addReplyArrayLen(c,4);
525 addReplyBulkCString(c,event);
526 addReplyLongLong(c,ts->samples[last].time);
527 addReplyLongLong(c,ts->samples[last].latency);
528 addReplyLongLong(c,ts->max);
529 }
530 dictReleaseIterator(di);
531}
532
533#define LATENCY_GRAPH_COLS 80
534sds latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) {

Callers 1

latencyCommandFunction · 0.85

Calls 6

addReplyArrayLenFunction · 0.85
addReplyBulkCStringFunction · 0.85
addReplyLongLongFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected