2016-01-17 13:34:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
#include <mutex>
|
|
|
|
#include <condition_variable>
|
|
|
|
|
|
|
|
#include <DB/Common/ProfileEvents.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-01-20 21:32:01 +00:00
|
|
|
/** Automatically sends
|
|
|
|
* - difference of ProfileEvents;
|
|
|
|
* - values of CurrentMetrics;
|
2016-10-24 02:02:37 +00:00
|
|
|
* - values of ActiveMetrics;
|
2016-01-20 21:32:01 +00:00
|
|
|
* to Graphite at beginning of every minute.
|
2016-01-17 13:34:36 +00:00
|
|
|
*/
|
|
|
|
class MetricsTransmitter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~MetricsTransmitter();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void run();
|
2016-01-20 21:32:01 +00:00
|
|
|
void transmit();
|
2016-01-17 13:34:36 +00:00
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
/// Values of ProfileEvents counters at previous iteration (or zeros at first time).
|
2016-01-17 13:34:36 +00:00
|
|
|
decltype(ProfileEvents::counters) prev_counters{};
|
|
|
|
|
|
|
|
bool quit = false;
|
|
|
|
std::mutex mutex;
|
|
|
|
std::condition_variable cond;
|
|
|
|
std::thread thread {&MetricsTransmitter::run, this};
|
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
static constexpr auto profile_events_path_prefix = "ClickHouse.ProfileEvents.";
|
|
|
|
static constexpr auto current_metrics_path_prefix = "ClickHouse.Metrics.";
|
|
|
|
static constexpr auto active_metrics_path_prefix = "ClickHouse.ActiveMetrics.";
|
2016-01-17 13:34:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|