2018-06-20 17:49:52 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Common/ProfileEvents.h>
|
2021-10-13 20:52:39 +00:00
|
|
|
#include <DataTypes/DataTypeEnum.h>
|
2018-06-20 17:49:52 +00:00
|
|
|
#include <Columns/IColumn.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
{
|
|
|
|
|
2022-02-15 08:25:07 +00:00
|
|
|
constexpr size_t NAME_COLUMN_INDEX = 4;
|
|
|
|
constexpr size_t VALUE_COLUMN_INDEX = 5;
|
|
|
|
|
|
|
|
struct ProfileEventsSnapshot
|
|
|
|
{
|
|
|
|
UInt64 thread_id;
|
|
|
|
ProfileEvents::CountersIncrement counters;
|
|
|
|
Int64 memory_usage;
|
|
|
|
time_t current_time;
|
|
|
|
};
|
|
|
|
|
|
|
|
using ThreadIdToCountersSnapshot = std::unordered_map<UInt64, ProfileEvents::Counters::Snapshot>;
|
|
|
|
|
2021-01-05 10:10:19 +00:00
|
|
|
/// Dumps profile events to columns Map(String, UInt64)
|
2021-10-11 15:56:23 +00:00
|
|
|
void dumpToMapColumn(const Counters::Snapshot & counters, DB::IColumn * column, bool nonzero_only = true);
|
2018-06-20 17:49:52 +00:00
|
|
|
|
2022-02-15 08:25:07 +00:00
|
|
|
/// Add records about provided non-zero ProfileEvents::Counters.
|
|
|
|
void dumpProfileEvents(ProfileEventsSnapshot const & snapshot, DB::MutableColumns & columns, String const & host_name);
|
|
|
|
|
|
|
|
void dumpMemoryTracker(ProfileEventsSnapshot const & snapshot, DB::MutableColumns & columns, String const & host_name);
|
|
|
|
|
2021-10-13 20:52:39 +00:00
|
|
|
/// This is for ProfileEvents packets.
|
|
|
|
enum Type : int8_t
|
|
|
|
{
|
|
|
|
INCREMENT = 1,
|
|
|
|
GAUGE = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern std::shared_ptr<DB::DataTypeEnum8> TypeEnum;
|
|
|
|
|
2018-06-20 17:49:52 +00:00
|
|
|
}
|