2016-01-17 13:34:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <condition_variable>
|
2017-03-21 19:08:09 +00:00
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
|
|
|
#include <vector>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/ProfileEvents.h>
|
2019-01-14 19:22:09 +00:00
|
|
|
#include <Common/ThreadPool.h>
|
2016-01-17 13:34:36 +00:00
|
|
|
|
|
|
|
|
2019-07-04 19:08:37 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
namespace Util
|
|
|
|
{
|
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-17 13:34:36 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2017-08-24 14:51:13 +00:00
|
|
|
|
2016-10-24 04:06:27 +00:00
|
|
|
class AsynchronousMetrics;
|
2017-08-24 14:51:13 +00:00
|
|
|
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2019-07-04 19:08:37 +00:00
|
|
|
/** Automatically sends
|
2016-01-20 21:32:01 +00:00
|
|
|
* - difference of ProfileEvents;
|
|
|
|
* - values of CurrentMetrics;
|
2016-10-24 04:06:27 +00:00
|
|
|
* - values of AsynchronousMetrics;
|
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:
|
2019-08-03 11:02:40 +00:00
|
|
|
MetricsTransmitter(const Poco::Util::AbstractConfiguration & config, const std::string & config_name_, const AsynchronousMetrics & async_metrics_);
|
2017-04-01 07:20:54 +00:00
|
|
|
~MetricsTransmitter();
|
2016-01-17 13:34:36 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
void run();
|
|
|
|
void transmit(std::vector<ProfileEvents::Count> & prev_counters);
|
2016-01-17 13:34:36 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
const AsynchronousMetrics & async_metrics;
|
2019-07-04 19:08:37 +00:00
|
|
|
|
|
|
|
std::string config_name;
|
|
|
|
UInt32 interval_seconds;
|
|
|
|
bool send_events;
|
|
|
|
bool send_metrics;
|
|
|
|
bool send_asynchronous_metrics;
|
2016-01-17 13:34:36 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
bool quit = false;
|
|
|
|
std::mutex mutex;
|
|
|
|
std::condition_variable cond;
|
2019-01-14 19:22:09 +00:00
|
|
|
ThreadFromGlobalPool thread{&MetricsTransmitter::run, this};
|
2016-01-17 13:34:36 +00:00
|
|
|
|
2019-07-04 19:08:37 +00:00
|
|
|
static inline constexpr auto profile_events_path_prefix = "ClickHouse.ProfileEvents.";
|
|
|
|
static inline constexpr auto current_metrics_path_prefix = "ClickHouse.Metrics.";
|
|
|
|
static inline constexpr auto asynchronous_metrics_path_prefix = "ClickHouse.AsynchronousMetrics.";
|
2016-01-17 13:34:36 +00:00
|
|
|
};
|
2017-08-24 14:51:13 +00:00
|
|
|
|
2016-01-17 13:34:36 +00:00
|
|
|
}
|