Skip to content

Commit

Permalink
added new confdata statshouse metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
DrDet committed Nov 13, 2024
1 parent f8148e9 commit 4319184
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/confdata-stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void ConfdataStats::on_update(const confdata_sample_storage &new_confdata,
predefined_wildcard_elements = 0;
heaviest_sections_by_count.clear();

total_rb_tree_size = new_confdata.size();

for (const auto &section: new_confdata) {
const vk::string_view first_key{section.first.c_str(), section.first.size()};
switch (confdata_predefined_wildcards.detect_first_key_type(first_key)) {
Expand Down Expand Up @@ -75,6 +77,9 @@ void ConfdataStats::on_update(const confdata_sample_storage &new_confdata,
}
}

if (last_update_time_point.time_since_epoch() > std::chrono::nanoseconds::zero()) {
time_since_last_update = std::chrono::steady_clock::now() - last_update_time_point;
}
last_update_time_point = std::chrono::steady_clock::now();
}

Expand Down
3 changes: 3 additions & 0 deletions server/confdata-stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct ConfdataStats : private vk::not_copyable {

std::chrono::nanoseconds initial_loading_time{std::chrono::nanoseconds::zero()};
std::chrono::nanoseconds total_updating_time{std::chrono::nanoseconds::zero()};
std::chrono::nanoseconds time_since_last_update{std::chrono::nanoseconds::zero()};
std::chrono::steady_clock::time_point last_update_time_point{std::chrono::nanoseconds::zero()};

size_t total_updates{0};
Expand All @@ -36,6 +37,8 @@ struct ConfdataStats : private vk::not_copyable {
size_t predefined_wildcard_elements{0};
size_t elements_with_delay{0};

size_t total_rb_tree_size{0};

struct EventCounters {
struct Event {
size_t total{0};
Expand Down
10 changes: 10 additions & 0 deletions server/statshouse/statshouse-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ void StatsHouseManager::add_confdata_master_stats(const ConfdataStats &confdata_
client.metric("kphp_confdata_memory").tag("used").write_value(memory_stats.memory_used);
client.metric("kphp_confdata_memory").tag("real_used").write_value(memory_stats.real_memory_used);

client.metric("kphp_confdata_tree_nodes").tag("no_dots").write_value(confdata_stats.simple_key_elements);
client.metric("kphp_confdata_tree_nodes").tag("one_dot").write_value(confdata_stats.one_dot_wildcards);
client.metric("kphp_confdata_tree_nodes").tag("two_dots").write_value(confdata_stats.two_dots_wildcards);
client.metric("kphp_confdata_tree_nodes").tag("predefined_wildcard").write_value(confdata_stats.predefined_wildcards);
client.metric("kphp_confdata_tree_nodes").tag("total").write_value(confdata_stats.total_rb_tree_size);

if (confdata_stats.time_since_last_update > std::chrono::nanoseconds::zero()) {
client.metric("kphp_confdata_time_since_last_update").write_value(confdata_stats.time_since_last_update.count());
}

const auto &events = confdata_stats.event_counters;
client.metric("kphp_confdata_events").tag("set").write_value(events.set_events.total + events.set_forever_events.total);
client.metric("kphp_confdata_events").tag("set_blacklisted").write_value(events.set_events.blacklisted + events.set_forever_events.blacklisted);
Expand Down

0 comments on commit 4319184

Please sign in to comment.