Skip to content

Commit

Permalink
add request load stats to statshouse
Browse files Browse the repository at this point in the history
  • Loading branch information
astrophysik committed Oct 16, 2023
1 parent 85ade3a commit da1ab96
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/server-stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,9 @@ void ServerStats::add_request_stats(double script_time_sec, double net_time_sec,
shared_stats_->workers.add_worker_stats(queries_stat, worker_process_id_);

StatsHouseManager::get().add_request_stats(script_time.count(), net_time.count(), error, memory_used, real_memory_used, script_queries, long_script_queries,
script_user_time.count(), script_system_time.count(), script_rusage.voluntary_context_switches, script_rusage.involuntary_context_switches);
script_user_time.count(), script_system_time.count(),
script_init_time.count(), http_connection_process_time.count(),
script_rusage.voluntary_context_switches, script_rusage.involuntary_context_switches);
}

void ServerStats::add_job_stats(double job_wait_time_sec, int64_t request_memory_used, int64_t request_real_memory_used, int64_t response_memory_used,
Expand Down
5 changes: 5 additions & 0 deletions server/statshouse/statshouse-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void StatsHouseManager::generic_cron_check_if_tag_host_needed() {
void StatsHouseManager::add_request_stats(uint64_t script_time_ns, uint64_t net_time_ns, script_error_t error, uint64_t memory_used,
uint64_t real_memory_used, uint64_t script_queries, uint64_t long_script_queries,
uint64_t script_user_time_ns, uint64_t script_system_time_ns,
uint64_t script_init_time, uint64_t http_connection_process_time,
uint64_t voluntary_context_switches, uint64_t involuntary_context_switches) {
const char *worker_type = get_current_worker_type();
const char *status = script_error_to_str(error);
Expand All @@ -106,11 +107,15 @@ void StatsHouseManager::add_request_stats(uint64_t script_time_ns, uint64_t net_
client.metric("kphp_request_time").tag("net").tag(worker_type).tag(status).write_value(net_time_ns);
client.metric("kphp_request_cpu_time").tag("user").tag(worker_type).tag(status).write_value(script_user_time_ns);
client.metric("kphp_request_cpu_time").tag("system").tag(worker_type).tag(status).write_value(script_system_time_ns);
client.metric("kphp_request_load_time").tag("script_init").tag(worker_type).tag(status).write_value(script_init_time);
client.metric("kphp_request_load_time").tag("http_connection_process").tag(worker_type).tag(status).write_value(http_connection_process_time);

client.metric("kphp_by_host_request_time", true).tag("script").tag(worker_type).write_value(script_time_ns);
client.metric("kphp_by_host_request_time", true).tag("net").tag(worker_type).write_value(net_time_ns);
client.metric("kphp_by_host_request_cpu_time", true).tag("user").tag(worker_type).tag(status).write_value(script_user_time_ns);
client.metric("kphp_by_host_request_cpu_time", true).tag("system").tag(worker_type).tag(status).write_value(script_system_time_ns);
client.metric("kphp_by_host_request_load_time", true).tag("script_init").tag(worker_type).tag(status).write_value(script_init_time);
client.metric("kphp_by_host_request_load_time", true).tag("http_connection_process").tag(worker_type).tag(status).write_value(http_connection_process_time);

if (error != script_error_t::no_error) {
client.metric("kphp_request_errors").tag(status).tag(worker_type).write_count(1);
Expand Down
1 change: 1 addition & 0 deletions server/statshouse/statshouse-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class StatsHouseManager : vk::not_copyable {
void add_request_stats(uint64_t script_time_ns, uint64_t net_time_ns, script_error_t error, uint64_t memory_used, uint64_t real_memory_used,
uint64_t script_queries, uint64_t long_script_queries,
uint64_t script_user_time_ns, uint64_t script_system_time_ns,
uint64_t script_init_time, uint64_t http_connection_process_time,
uint64_t voluntary_context_switches, uint64_t involuntary_context_switches);

void add_job_stats(uint64_t job_wait_ns, uint64_t request_memory_used, uint64_t request_real_memory_used, uint64_t response_memory_used,
Expand Down

0 comments on commit da1ab96

Please sign in to comment.