Skip to content

Commit 00a6f90

Browse files
authored
chore: change the resolution of reply latency to measurement to ns (#6092)
Align test_reply_count to use /metrics for fetching the `reply_count` counter.
1 parent a7f358e commit 00a6f90

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/facade/reply_builder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void SinkReplyBuilder::Send() {
181181

182182
uint64_t after_ns = util::fb2::ProactorBase::GetMonotonicTimeNs();
183183
reply_stats.send_stats.count++;
184-
reply_stats.send_stats.total_duration += (after_ns - pin.timestamp_ns) / 1'000;
184+
reply_stats.send_stats.total_duration += (after_ns - pin.timestamp_ns);
185185
DVLOG(2) << "Finished writing " << total_size_ << " bytes";
186186
}
187187

src/server/server_family.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
17131713
MetricType::COUNTER, &resp->body());
17141714
{
17151715
AppendMetricWithoutLabels("reply_duration_seconds", "",
1716-
m.facade_stats.reply_stats.send_stats.total_duration * 1e-6,
1716+
m.facade_stats.reply_stats.send_stats.total_duration * 1e-9,
17171717
MetricType::COUNTER, &resp->body());
17181718
AppendMetricWithoutLabels("reply_total", "", m.facade_stats.reply_stats.send_stats.count,
17191719
MetricType::COUNTER, &resp->body());
@@ -3061,8 +3061,6 @@ string ServerFamily::FormatInfoMetrics(const Metrics& m, std::string_view sectio
30613061
append("defrag_attempt_total", m.shard_stats.defrag_attempt_total);
30623062
append("defrag_realloc_total", m.shard_stats.defrag_realloc_total);
30633063
append("defrag_task_invocation_total", m.shard_stats.defrag_task_invocation_total);
3064-
append("reply_count", reply_stats.send_stats.count);
3065-
append("reply_latency_usec", reply_stats.send_stats.total_duration);
30663064

30673065
// Number of connections that are currently blocked on grabbing interpreter.
30683066
append("blocked_on_interpreter", m.coordinator_stats.blocked_on_interpreter);

tests/dragonfly/connection_test.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,21 +607,23 @@ async def test_keyspace_events_config_set(async_client: aioredis.Redis):
607607

608608

609609
@dfly_args({"max_busy_read_usec": 50000})
610-
async def test_reply_count(async_client: aioredis.Redis):
610+
async def test_reply_count(df_server: DflyInstance):
611611
"""Make sure reply aggregations reduce reply counts for common cases"""
612612

613613
async def get_reply_count():
614-
return (await async_client.info("STATS"))["reply_count"]
614+
metrics = await df_server.metrics()
615+
return int(metrics["dragonfly_reply"].samples[0].value)
615616

616617
async def measure(aw):
617618
before = await get_reply_count()
618619
await aw
619-
return await get_reply_count() - before - 1
620+
return await get_reply_count() - before
620621

622+
async_client = df_server.client()
621623
await async_client.config_resetstat()
622624
base = await get_reply_count()
623625
info_diff = await get_reply_count() - base
624-
assert info_diff == 1
626+
assert info_diff == 0 # no commands yet
625627

626628
# Warm client buffer up
627629
await async_client.lpush("warmup", *(i for i in range(500)))

0 commit comments

Comments
 (0)