Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): Cluster MOVED response Prometheus metric #4786

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Changes from 1 commit
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
19 changes: 15 additions & 4 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1520,12 +1520,23 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
}

if (IsClusterEnabled()) {
string str;
string migration_errors_str;
AppendMetricHeader("migration_errors_total", "Total error numbers of current migrations",
MetricType::GAUGE, &str);
MetricType::GAUGE, &migration_errors_str);
AppendMetricValue("migration_errors_total", m.migration_errors_total, {"num"},
{"migration errors"}, &str);
absl::StrAppend(&resp->body(), str);
{"migration errors"}, &migration_errors_str);
absl::StrAppend(&resp->body(), migration_errors_str);

string moved_errors_str;
uint64_t moved_total_errors = 0;
if (m.facade_stats.reply_stats.err_count.contains("MOVED")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

here it's okeyish, but I prefer we do not use double-find patterns. This is why god stroustroup created iterators.

moved_total_errors = m.facade_stats.reply_stats.err_count.at("MOVED");
}
AppendMetricHeader("moved_errors_total", "Total error numbers of moved slot errors",
MetricType::COUNTER, &moved_errors_str);
AppendMetricValue("moved_errors_total", moved_total_errors, {"num"}, {"moved errors"},
&moved_errors_str);
absl::StrAppend(&resp->body(), moved_errors_str);
}

string db_key_metrics;
Expand Down
Loading