Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/facade/reply_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void SinkReplyBuilder::Send() {

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

Expand Down
4 changes: 1 addition & 3 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
MetricType::COUNTER, &resp->body());
{
AppendMetricWithoutLabels("reply_duration_seconds", "",
m.facade_stats.reply_stats.send_stats.total_duration * 1e-6,
m.facade_stats.reply_stats.send_stats.total_duration * 1e-9,
MetricType::COUNTER, &resp->body());
AppendMetricWithoutLabels("reply_total", "", m.facade_stats.reply_stats.send_stats.count,
MetricType::COUNTER, &resp->body());
Expand Down Expand Up @@ -3015,8 +3015,6 @@ string ServerFamily::FormatInfoMetrics(const Metrics& m, std::string_view sectio
append("defrag_attempt_total", m.shard_stats.defrag_attempt_total);
append("defrag_realloc_total", m.shard_stats.defrag_realloc_total);
append("defrag_task_invocation_total", m.shard_stats.defrag_task_invocation_total);
append("reply_count", reply_stats.send_stats.count);
append("reply_latency_usec", reply_stats.send_stats.total_duration);

// Number of connections that are currently blocked on grabbing interpreter.
append("blocked_on_interpreter", m.coordinator_stats.blocked_on_interpreter);
Expand Down
10 changes: 6 additions & 4 deletions tests/dragonfly/connection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,21 +607,23 @@ async def test_keyspace_events_config_set(async_client: aioredis.Redis):


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

async def get_reply_count():
return (await async_client.info("STATS"))["reply_count"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before: the info call intervened with the test, now we scrape /metrics

metrics = await df_server.metrics()
return int(metrics["dragonfly_reply"].samples[0].value)

async def measure(aw):
before = await get_reply_count()
await aw
return await get_reply_count() - before - 1
return await get_reply_count() - before

async_client = df_server.client()
await async_client.config_resetstat()
base = await get_reply_count()
info_diff = await get_reply_count() - base
assert info_diff == 1
assert info_diff == 0 # no commands yet

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