ClickHouse/programs/server/MetricsTransmitter.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.6 KiB
C++
Raw Normal View History

2016-01-17 13:34:36 +00:00
#pragma once
#include <condition_variable>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
#include <optional>
#include <Core/Types.h>
#include <Common/ThreadPool.h>
#include <Common/ProfileEvents.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
{
class AsynchronousMetrics;
2019-07-04 19:08:37 +00:00
/** Automatically sends
2019-09-22 22:57:06 +00:00
* - delta values of ProfileEvents;
* - cumulative values 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:
2019-08-03 11:02:40 +00:00
MetricsTransmitter(const Poco::Util::AbstractConfiguration & config, const std::string & config_name_, const AsynchronousMetrics & 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;
2019-07-04 19:08:37 +00:00
std::string config_name;
UInt32 interval_seconds;
bool send_events;
2019-09-22 22:57:06 +00:00
bool send_events_cumulative;
2019-07-04 19:08:37 +00:00
bool send_metrics;
bool send_asynchronous_metrics;
2016-01-17 13:34:36 +00:00
bool quit = false;
std::mutex mutex;
std::condition_variable cond;
std::optional<ThreadFromGlobalPool> thread;
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.";
2019-09-22 22:57:06 +00:00
static inline constexpr auto profile_events_cumulative_path_prefix = "ClickHouse.ProfileEventsCumulative.";
2019-07-04 19:08:37 +00:00
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
};
2016-01-17 13:34:36 +00:00
}