Skip to content

Commit

Permalink
Send kphp_version StatsHouse metric as count (not value) metric (#1066
Browse files Browse the repository at this point in the history
)
  • Loading branch information
DrDet authored Aug 15, 2024
1 parent f8139d0 commit 49415b2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions runtime/php_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "server/php-engine-vars.h"

const char *engine_tag = "[";
long long engine_tag_number = 0;

const char *engine_pid = "] ";

int php_disable_warnings = 0;
Expand Down
2 changes: 2 additions & 0 deletions runtime/php_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
extern int die_on_fail;

extern const char *engine_tag;
extern long long engine_tag_number;

extern const char *engine_pid;

extern int php_disable_warnings;
Expand Down
1 change: 1 addition & 0 deletions server/php-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,7 @@ int main_args_handler(int i, const char *long_option) {
}
case 'E': {
read_engine_tag(optarg);
engine_tag_number = atoll(engine_tag);
return 0;
}
case 'm': {
Expand Down
4 changes: 2 additions & 2 deletions server/php-master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ std::string php_master_prepare_stats(bool add_worker_pids) {
oss << "uptime\t" << get_uptime() << "\n";
if (engine_tag) {
// engine_tag may be ended with "["
oss << "kphp_version\t" << atoll(engine_tag) << "\n";
oss << "kphp_version\t" << engine_tag_number << "\n";
}
const auto &config = vk::singleton<ServerConfig>::get();
if (!config.get_environment().empty()) {
Expand Down Expand Up @@ -1105,7 +1105,7 @@ static long long int instance_cache_memory_swaps_fail = 0;

STATS_PROVIDER_TAGGED(kphp_stats, 100, stats_tag_kphp_server) {
if (engine_tag) {
stats->add_gauge_stat("kphp_version", atoll(engine_tag));
stats->add_gauge_stat("kphp_version", engine_tag_number);
}

stats->add_gauge_stat("uptime", get_uptime());
Expand Down
3 changes: 2 additions & 1 deletion server/statshouse/statshouse-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "server/statshouse/statshouse-manager.h"

#include <chrono>
#include <string>

#include "common/precise-time.h"
#include "common/resolver.h"
Expand Down Expand Up @@ -181,7 +182,7 @@ void StatsHouseManager::add_common_master_stats(const workers_stats_t &workers_s
double cpu_s_usage, double cpu_u_usage,
long long int instance_cache_memory_swaps_ok, long long int instance_cache_memory_swaps_fail) {
if (engine_tag) {
client.metric("kphp_version").write_value(atoll(engine_tag));
client.metric("kphp_version").tag(std::to_string(engine_tag_number)).write_count(1);
}

client.metric("kphp_uptime").write_value(get_uptime());
Expand Down

0 comments on commit 49415b2

Please sign in to comment.