2018-06-20 17:49:52 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Common/ProfileEvents.h>
|
2022-03-01 07:54:23 +00:00
|
|
|
#include <Common/ThreadStatus.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;
|
2022-02-15 12:26:53 +00:00
|
|
|
CountersIncrement counters;
|
2022-02-15 08:25:07 +00:00
|
|
|
Int64 memory_usage;
|
|
|
|
time_t current_time;
|
|
|
|
};
|
|
|
|
|
2022-02-15 12:26:53 +00:00
|
|
|
using ThreadIdToCountersSnapshot = std::unordered_map<UInt64, Counters::Snapshot>;
|
2022-02-15 08:25:07 +00:00
|
|
|
|
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-03-01 07:54:23 +00:00
|
|
|
void getProfileEvents(
|
|
|
|
const String & server_display_name,
|
|
|
|
DB::InternalProfileEventsQueuePtr profile_queue,
|
|
|
|
DB::Block & block,
|
|
|
|
ThreadIdToCountersSnapshot & last_sent_snapshots);
|
2022-02-15 08:25:07 +00:00
|
|
|
|
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
|
|
|
}
|