Skip to content

Commit

Permalink
fix(metrics): add corresponding comments to command metrics (#4674)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Lewis <lewis@ourzora.com>
  • Loading branch information
Yomanz authored and romange committed Mar 9, 2025
1 parent 4f91030 commit 21b19e9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1447,15 +1447,21 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
if (!m.cmd_stats_map.empty()) {
string command_metrics;

AppendMetricHeader("commands", "Metrics for all commands ran", MetricType::COUNTER,
AppendMetricHeader("commands_total", "Total number of commands executed", MetricType::COUNTER,
&command_metrics);
for (const auto& [name, stat] : m.cmd_stats_map) {
const auto calls = stat.first;
const double duration_seconds = stat.second * 1e-6;
AppendMetricValue("commands_total", calls, {"cmd"}, {name}, &command_metrics);
}

AppendMetricHeader("commands_duration_seconds", "Duration of commands in seconds",
MetricType::HISTOGRAM, &command_metrics);
for (const auto& [name, stat] : m.cmd_stats_map) {
const double duration_seconds = stat.second * 1e-6;
AppendMetricValue("commands_duration_seconds", duration_seconds, {"cmd"}, {name},
&command_metrics);
}

absl::StrAppend(&resp->body(), command_metrics);
}

Expand Down

0 comments on commit 21b19e9

Please sign in to comment.