Loading include/client/env.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ static constexpr auto FORWARDING_MAP_FILE = ADD_PREFIX("FORWARDING_MAP_FILE"); static constexpr auto ENABLE_METRICS = ADD_PREFIX("ENABLE_METRICS"); static constexpr auto METRICS_INTERVAL = ADD_PREFIX("METRICS_INTERVAL"); static constexpr auto METRICS_PATH = ADD_PREFIX("METRICS_PATH"); static constexpr auto METRICS_IP_PORT = ADD_PREFIX("METRICS_IP_PORT"); #endif static constexpr auto NUM_REPL = ADD_PREFIX("NUM_REPL"); Loading include/client/preload_context.hpp +1 −3 Original line number Diff line number Diff line Loading @@ -55,8 +55,6 @@ namespace messagepack { class ClientMetrics; } namespace preload { /* * Client file system config Loading Loading @@ -133,7 +131,7 @@ public: void init_logging(); void bool init_metrics(); void Loading include/common/msgpack_util.hpp +49 −22 Original line number Diff line number Diff line Loading @@ -41,41 +41,62 @@ namespace gkfs::messagepack { enum class client_metric_type { write, read }; enum class client_metric_io_type { write, read }; enum class client_metric_flush_type { file, socket }; class ClientMetrics { public: // std::mutex mtx_{}; // std::thread thread_{}; /* * MessagePack data structure for client metrics. Includes only what is * actually sent */ struct msgpack_data { std::chrono::time_point<std::chrono::system_clock> init_t_; std::string hostname_; int pid_; // in microseconds std::string io_type_; std::vector<uint32_t> start_t_{}; std::vector<uint32_t> end_t_{}; // in bytes std::vector<uint32_t> req_size_{}; uint32_t total_bytes_{}; int total_iops_{0}; template <class T> void pack(T& pack) { pack(init_t_, hostname_, pid_, io_type_, start_t_, end_t_, req_size_, total_iops_, total_bytes_); } std::vector<uint8_t> pack_msgpack() { return msgpack::pack(*this); } }; private: msgpack_data msgpack_data_{}; zmq::context_t zmq_context_; zmq::socket_t zmq_socket_; // std::mutex mtx_{}; // std::thread thread_{}; client_metric_flush_type flush_type_{client_metric_flush_type::file}; bool is_enabled_{false}; std::string path_{}; // public: ClientMetrics(); public: ClientMetrics() = default; ~ClientMetrics() = default; explicit ClientMetrics(client_metric_io_type io_type, client_metric_flush_type flush_type = client_metric_flush_type::file); template <class T> void pack(T& pack) { pack(init_t_, hostname_, pid_, start_t_, end_t_, req_size_, total_iops_, total_bytes_); } ~ClientMetrics(); void add_event(size_t size, Loading @@ -90,6 +111,12 @@ public: void disable(); void zmq_connect(const std::string& ip_port); bool zmq_is_connected(); [[nodiscard]] const std::string& path() const; Loading include/config.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ constexpr auto forwarding_file_path = ""; namespace metrics { // Default directory where client metrics are stored. Can be set via // LIBGKFS_METRICS_PATH. Filename consists of starting time, pid, and hostname // Note: when LIBGKFS_METRICS_IP is given, ZeroMQ is used instead constexpr auto client_metrics_path = "/tmp/gkfs_client_metrics"; } // namespace metrics Loading src/client/preload.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,10 @@ init_preload() { init_forwarding_mapper(); } #ifdef GKFS_ENABLE_CLIENT_METRICS CTX->init_metrics(); if(!CTX->init_metrics()) { exit_error_msg(EXIT_FAILURE, "Unable to initialize client metrics. Exiting..."); } #endif gkfs::preload::start_interception(); Loading Loading
include/client/env.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ static constexpr auto FORWARDING_MAP_FILE = ADD_PREFIX("FORWARDING_MAP_FILE"); static constexpr auto ENABLE_METRICS = ADD_PREFIX("ENABLE_METRICS"); static constexpr auto METRICS_INTERVAL = ADD_PREFIX("METRICS_INTERVAL"); static constexpr auto METRICS_PATH = ADD_PREFIX("METRICS_PATH"); static constexpr auto METRICS_IP_PORT = ADD_PREFIX("METRICS_IP_PORT"); #endif static constexpr auto NUM_REPL = ADD_PREFIX("NUM_REPL"); Loading
include/client/preload_context.hpp +1 −3 Original line number Diff line number Diff line Loading @@ -55,8 +55,6 @@ namespace messagepack { class ClientMetrics; } namespace preload { /* * Client file system config Loading Loading @@ -133,7 +131,7 @@ public: void init_logging(); void bool init_metrics(); void Loading
include/common/msgpack_util.hpp +49 −22 Original line number Diff line number Diff line Loading @@ -41,41 +41,62 @@ namespace gkfs::messagepack { enum class client_metric_type { write, read }; enum class client_metric_io_type { write, read }; enum class client_metric_flush_type { file, socket }; class ClientMetrics { public: // std::mutex mtx_{}; // std::thread thread_{}; /* * MessagePack data structure for client metrics. Includes only what is * actually sent */ struct msgpack_data { std::chrono::time_point<std::chrono::system_clock> init_t_; std::string hostname_; int pid_; // in microseconds std::string io_type_; std::vector<uint32_t> start_t_{}; std::vector<uint32_t> end_t_{}; // in bytes std::vector<uint32_t> req_size_{}; uint32_t total_bytes_{}; int total_iops_{0}; template <class T> void pack(T& pack) { pack(init_t_, hostname_, pid_, io_type_, start_t_, end_t_, req_size_, total_iops_, total_bytes_); } std::vector<uint8_t> pack_msgpack() { return msgpack::pack(*this); } }; private: msgpack_data msgpack_data_{}; zmq::context_t zmq_context_; zmq::socket_t zmq_socket_; // std::mutex mtx_{}; // std::thread thread_{}; client_metric_flush_type flush_type_{client_metric_flush_type::file}; bool is_enabled_{false}; std::string path_{}; // public: ClientMetrics(); public: ClientMetrics() = default; ~ClientMetrics() = default; explicit ClientMetrics(client_metric_io_type io_type, client_metric_flush_type flush_type = client_metric_flush_type::file); template <class T> void pack(T& pack) { pack(init_t_, hostname_, pid_, start_t_, end_t_, req_size_, total_iops_, total_bytes_); } ~ClientMetrics(); void add_event(size_t size, Loading @@ -90,6 +111,12 @@ public: void disable(); void zmq_connect(const std::string& ip_port); bool zmq_is_connected(); [[nodiscard]] const std::string& path() const; Loading
include/config.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ constexpr auto forwarding_file_path = ""; namespace metrics { // Default directory where client metrics are stored. Can be set via // LIBGKFS_METRICS_PATH. Filename consists of starting time, pid, and hostname // Note: when LIBGKFS_METRICS_IP is given, ZeroMQ is used instead constexpr auto client_metrics_path = "/tmp/gkfs_client_metrics"; } // namespace metrics Loading
src/client/preload.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -296,7 +296,10 @@ init_preload() { init_forwarding_mapper(); } #ifdef GKFS_ENABLE_CLIENT_METRICS CTX->init_metrics(); if(!CTX->init_metrics()) { exit_error_msg(EXIT_FAILURE, "Unable to initialize client metrics. Exiting..."); } #endif gkfs::preload::start_interception(); Loading