From 16c28db384adbe61034eb8a2267cd6a886ffd72f Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Thu, 1 Dec 2016 21:42:51 +0100 Subject: Added the client side code for the statsd in the nodes. --- libcmix-common/performanceclient.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 libcmix-common/performanceclient.cpp (limited to 'libcmix-common/performanceclient.cpp') diff --git a/libcmix-common/performanceclient.cpp b/libcmix-common/performanceclient.cpp new file mode 100644 index 0000000..70953a8 --- /dev/null +++ b/libcmix-common/performanceclient.cpp @@ -0,0 +1,29 @@ +#include "performanceclient.hpp" + +#include + +#include + +PerformanceClient::PerformanceClient(std::string name, boost::asio::io_service& io_service, std::string host, std::string port) +: node_name(name) +, sender(std::unique_ptr(new boost::asio::ip::tcp::socket(io_service))) +, timer() +{ + timer.start(); + sender.async_connect(host, port, []{}); +} + +void PerformanceClient::send(std::string column) +{ + cmix_proto::Performance perf; + perf.set_node(node_name); + perf.set_column(column); + + auto tp = timer.elapsed(); + + perf.set_wall_time(std::to_string(tp.wall)); + perf.set_user_time(std::to_string(tp.user)); + perf.set_system_time(std::to_string(tp.system)); + + sender.async_send(perf); +} -- cgit v1.2.3-70-g09d2