ClickHouse/dbms/src/Server/MetricsTransmitter.h

45 lines
1.0 KiB
C++
Raw Normal View History

2016-01-17 13:34:36 +00:00
#pragma once
2016-11-01 17:56:25 +00:00
#include <vector>
2016-01-17 13:34:36 +00:00
#include <thread>
#include <mutex>
#include <condition_variable>
#include <DB/Common/ProfileEvents.h>
namespace DB
{
class AsynchronousMetrics;
/** Automatically sends
* - difference of ProfileEvents;
* - values of CurrentMetrics;
* - values of AsynchronousMetrics;
* to Graphite at beginning of every minute.
2016-01-17 13:34:36 +00:00
*/
class MetricsTransmitter
{
public:
MetricsTransmitter(const AsynchronousMetrics & async_metrics_) : async_metrics(async_metrics_) {}
2016-01-17 13:34:36 +00:00
~MetricsTransmitter();
private:
void run();
2016-11-01 17:56:25 +00:00
void transmit(std::vector<ProfileEvents::Count> & prev_counters);
2016-01-17 13:34:36 +00:00
const AsynchronousMetrics & async_metrics;
2016-01-17 13:34:36 +00:00
bool quit = false;
std::mutex mutex;
std::condition_variable cond;
std::thread thread {&MetricsTransmitter::run, this};
static constexpr auto profile_events_path_prefix = "ClickHouse.ProfileEvents.";
static constexpr auto current_metrics_path_prefix = "ClickHouse.Metrics.";
static constexpr auto asynchronous_metrics_path_prefix = "ClickHouse.AsynchronousMetrics.";
2016-01-17 13:34:36 +00:00
};
}