2015-06-22 21:26:03 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2016-10-27 17:48:12 +00:00
|
|
|
|
#include <DB/Interpreters/SystemLog.h>
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Позволяет логгировать информацию о выполнении запросов:
|
|
|
|
|
* - о начале выполнения запроса;
|
|
|
|
|
* - метрики производительности, после выполнения запроса;
|
|
|
|
|
* - об ошибках при выполнении запроса.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** Что логгировать.
|
|
|
|
|
*/
|
|
|
|
|
struct QueryLogElement
|
|
|
|
|
{
|
|
|
|
|
enum Type
|
|
|
|
|
{
|
|
|
|
|
QUERY_START = 1,
|
|
|
|
|
QUERY_FINISH = 2,
|
2015-07-01 05:18:54 +00:00
|
|
|
|
EXCEPTION_BEFORE_START = 3,
|
|
|
|
|
EXCEPTION_WHILE_PROCESSING = 4,
|
2015-06-22 21:26:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
2015-06-26 20:48:10 +00:00
|
|
|
|
Type type = QUERY_START;
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
|
|
|
|
/// В зависимости от типа, не все поля могут быть заполнены.
|
|
|
|
|
|
2015-06-26 20:48:10 +00:00
|
|
|
|
time_t event_time{};
|
|
|
|
|
time_t query_start_time{};
|
|
|
|
|
UInt64 query_duration_ms{};
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
2015-06-26 20:48:10 +00:00
|
|
|
|
UInt64 read_rows{};
|
|
|
|
|
UInt64 read_bytes{};
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
2015-06-26 20:48:10 +00:00
|
|
|
|
UInt64 result_rows{};
|
|
|
|
|
UInt64 result_bytes{};
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
2015-07-01 05:18:54 +00:00
|
|
|
|
UInt64 memory_usage{};
|
|
|
|
|
|
2015-06-22 21:26:03 +00:00
|
|
|
|
String query;
|
|
|
|
|
|
2015-06-29 21:35:35 +00:00
|
|
|
|
String exception;
|
|
|
|
|
String stack_trace;
|
|
|
|
|
|
2016-10-24 21:40:39 +00:00
|
|
|
|
ClientInfo client_info;
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
2016-10-27 17:48:12 +00:00
|
|
|
|
static std::string name() { return "QueryLog"; }
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
2016-10-27 17:48:12 +00:00
|
|
|
|
static Block createBlock();
|
|
|
|
|
void appendToBlock(Block & block) const;
|
|
|
|
|
};
|
2015-06-26 19:23:25 +00:00
|
|
|
|
|
2015-06-22 21:26:03 +00:00
|
|
|
|
|
2016-10-27 17:48:12 +00:00
|
|
|
|
/// Instead of typedef - to allow forward declaration.
|
|
|
|
|
class QueryLog : public SystemLog<QueryLogElement>
|
2015-06-22 21:26:03 +00:00
|
|
|
|
{
|
2016-10-27 17:48:12 +00:00
|
|
|
|
using SystemLog<QueryLogElement>::SystemLog;
|
2015-06-22 21:26:03 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|