ClickHouse/src/Interpreters/QueryViewsLog.h

89 lines
2.0 KiB
C++
Raw Normal View History

2021-06-15 17:10:41 +00:00
#pragma once
2021-06-18 13:44:08 +00:00
#include <chrono>
2021-06-15 17:10:41 +00:00
#include <memory>
#include <sys/types.h>
#include <Columns/IColumn.h>
#include <Core/Block.h>
#include <Core/SettingsEnums.h>
#include <Core/Types.h>
#include <Core/UUID.h>
#include <Interpreters/SystemLog.h>
2021-10-02 07:13:14 +00:00
#include <base/types.h>
2021-06-15 17:10:41 +00:00
namespace ProfileEvents
{
class Counters;
}
namespace DB
{
2021-06-18 13:44:08 +00:00
class ThreadStatus;
struct QueryViewsLogElement
2021-06-15 17:10:41 +00:00
{
using ViewStatus = QueryLogElementType;
2021-06-18 13:44:08 +00:00
enum class ViewType : int8_t
{
DEFAULT = 1,
MATERIALIZED = 2,
2021-11-19 13:09:12 +00:00
LIVE = 3,
WINDOW = 4,
2021-06-18 13:44:08 +00:00
};
struct ViewRuntimeStats
{
2021-06-18 16:25:19 +00:00
String target_name;
2021-06-18 13:44:08 +00:00
ViewType type = ViewType::DEFAULT;
std::unique_ptr<ThreadStatus> thread_status = nullptr;
2021-09-21 10:35:41 +00:00
std::atomic_uint64_t elapsed_ms = 0;
2021-06-18 16:25:19 +00:00
std::chrono::time_point<std::chrono::system_clock> event_time;
ViewStatus event_status = ViewStatus::QUERY_START;
2021-06-18 16:25:19 +00:00
void setStatus(ViewStatus s)
2021-06-18 16:25:19 +00:00
{
event_status = s;
event_time = std::chrono::system_clock::now();
}
2021-06-18 13:44:08 +00:00
};
2021-06-15 17:10:41 +00:00
time_t event_time{};
Decimal64 event_time_microseconds{};
2021-06-18 13:44:08 +00:00
UInt64 view_duration_ms{};
2021-06-15 17:10:41 +00:00
String initial_query_id;
2021-06-18 13:44:08 +00:00
String view_name;
UUID view_uuid{UUIDHelpers::Nil};
ViewType view_type{ViewType::DEFAULT};
String view_query;
String view_target;
2021-06-15 17:10:41 +00:00
UInt64 read_rows{};
UInt64 read_bytes{};
UInt64 written_rows{};
UInt64 written_bytes{};
Int64 peak_memory_usage{};
std::shared_ptr<ProfileEvents::Counters::Snapshot> profile_counters;
2021-06-15 17:10:41 +00:00
2021-06-29 09:25:34 +00:00
ViewStatus status = ViewStatus::QUERY_START;
2021-06-15 17:10:41 +00:00
Int32 exception_code{};
String exception;
String stack_trace;
2021-06-29 13:43:04 +00:00
static std::string name() { return "QueryLog"; }
2021-06-15 17:10:41 +00:00
2021-06-29 13:43:04 +00:00
static NamesAndTypesList getNamesAndTypes();
static NamesAndAliases getNamesAndAliases();
2021-06-15 17:10:41 +00:00
void appendToBlock(MutableColumns & columns) const;
};
2021-06-18 13:44:08 +00:00
class QueryViewsLog : public SystemLog<QueryViewsLogElement>
2021-06-15 17:10:41 +00:00
{
2021-06-18 13:44:08 +00:00
using SystemLog<QueryViewsLogElement>::SystemLog;
2021-06-15 17:10:41 +00:00
};
}