提交 1830df1d 编写于 作者: B bharatnc 提交者: alesapin

Query,QueryThread Logs - add event_time_microseconds field

上级 c6b5ef11
...@@ -39,6 +39,7 @@ Block QueryLogElement::createBlock() ...@@ -39,6 +39,7 @@ Block QueryLogElement::createBlock()
{std::move(query_status_datatype), "type"}, {std::move(query_status_datatype), "type"},
{std::make_shared<DataTypeDate>(), "event_date"}, {std::make_shared<DataTypeDate>(), "event_date"},
{std::make_shared<DataTypeDateTime>(), "event_time"}, {std::make_shared<DataTypeDateTime>(), "event_time"},
{std::make_shared<DataTypeDateTime64>(6), "event_time_microseconds"},
{std::make_shared<DataTypeDateTime>(), "query_start_time"}, {std::make_shared<DataTypeDateTime>(), "query_start_time"},
{std::make_shared<DataTypeDateTime64>(6), "query_start_time_microseconds"}, {std::make_shared<DataTypeDateTime64>(6), "query_start_time_microseconds"},
{std::make_shared<DataTypeUInt64>(), "query_duration_ms"}, {std::make_shared<DataTypeUInt64>(), "query_duration_ms"},
...@@ -97,6 +98,7 @@ void QueryLogElement::appendToBlock(MutableColumns & columns) const ...@@ -97,6 +98,7 @@ void QueryLogElement::appendToBlock(MutableColumns & columns) const
columns[i++]->insert(type); columns[i++]->insert(type);
columns[i++]->insert(DateLUT::instance().toDayNum(event_time)); columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
columns[i++]->insert(event_time); columns[i++]->insert(event_time);
columns[i++]->insert(event_time_microseconds);
columns[i++]->insert(query_start_time); columns[i++]->insert(query_start_time);
columns[i++]->insert(query_start_time_microseconds); columns[i++]->insert(query_start_time_microseconds);
columns[i++]->insert(query_duration_ms); columns[i++]->insert(query_duration_ms);
......
...@@ -30,6 +30,7 @@ struct QueryLogElement ...@@ -30,6 +30,7 @@ struct QueryLogElement
/// Depending on the type of query and type of stage, not all the fields may be filled. /// Depending on the type of query and type of stage, not all the fields may be filled.
time_t event_time{}; time_t event_time{};
UInt64 event_time_microseconds{};
time_t query_start_time{}; time_t query_start_time{};
UInt64 query_start_time_microseconds{}; UInt64 query_start_time_microseconds{};
UInt64 query_duration_ms{}; UInt64 query_duration_ms{};
......
...@@ -23,6 +23,7 @@ Block QueryThreadLogElement::createBlock() ...@@ -23,6 +23,7 @@ Block QueryThreadLogElement::createBlock()
return { return {
{std::make_shared<DataTypeDate>(), "event_date"}, {std::make_shared<DataTypeDate>(), "event_date"},
{std::make_shared<DataTypeDateTime>(), "event_time"}, {std::make_shared<DataTypeDateTime>(), "event_time"},
{std::make_shared<DataTypeDateTime64>(6), "event_time_microseconds"},
{std::make_shared<DataTypeDateTime>(), "query_start_time"}, {std::make_shared<DataTypeDateTime>(), "query_start_time"},
{std::make_shared<DataTypeDateTime64>(6), "query_start_time_microseconds"}, {std::make_shared<DataTypeDateTime64>(6), "query_start_time_microseconds"},
{std::make_shared<DataTypeUInt64>(), "query_duration_ms"}, {std::make_shared<DataTypeUInt64>(), "query_duration_ms"},
...@@ -73,6 +74,7 @@ void QueryThreadLogElement::appendToBlock(MutableColumns & columns) const ...@@ -73,6 +74,7 @@ void QueryThreadLogElement::appendToBlock(MutableColumns & columns) const
columns[i++]->insert(DateLUT::instance().toDayNum(event_time)); columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
columns[i++]->insert(event_time); columns[i++]->insert(event_time);
columns[i++]->insert(event_time_microseconds);
columns[i++]->insert(query_start_time); columns[i++]->insert(query_start_time);
columns[i++]->insert(query_start_time_microseconds); columns[i++]->insert(query_start_time_microseconds);
columns[i++]->insert(query_duration_ms); columns[i++]->insert(query_duration_ms);
......
...@@ -16,6 +16,7 @@ namespace DB ...@@ -16,6 +16,7 @@ namespace DB
struct QueryThreadLogElement struct QueryThreadLogElement
{ {
time_t event_time{}; time_t event_time{};
UInt64 event_time_microseconds{};
/// When query was attached to current thread /// When query was attached to current thread
time_t query_start_time{}; time_t query_start_time{};
/// same as above but adds microsecond precision /// same as above but adds microsecond precision
......
...@@ -323,6 +323,7 @@ void ThreadStatus::logToQueryThreadLog(QueryThreadLog & thread_log) ...@@ -323,6 +323,7 @@ void ThreadStatus::logToQueryThreadLog(QueryThreadLog & thread_log)
QueryThreadLogElement elem; QueryThreadLogElement elem;
elem.event_time = time(nullptr); elem.event_time = time(nullptr);
elem.event_time_microseconds = getCurrentTimeMicroseconds();
elem.query_start_time = query_start_time; elem.query_start_time = query_start_time;
elem.query_start_time_microseconds = query_start_time_microseconds; elem.query_start_time_microseconds = query_start_time_microseconds;
elem.query_duration_ms = (getCurrentTimeNanoseconds() - query_start_time_nanoseconds) / 1000000U; elem.query_duration_ms = (getCurrentTimeNanoseconds() - query_start_time_nanoseconds) / 1000000U;
......
...@@ -210,6 +210,7 @@ static void onExceptionBeforeStart(const String & query_for_logging, Context & c ...@@ -210,6 +210,7 @@ static void onExceptionBeforeStart(const String & query_for_logging, Context & c
// event_time_microseconds from the same timespec. So it can be assumed that both of these // event_time_microseconds from the same timespec. So it can be assumed that both of these
// times are equal upto the precision of a second. // times are equal upto the precision of a second.
elem.event_time = current_time; elem.event_time = current_time;
elem.event_time_microseconds = current_time_microseconds;
elem.query_start_time = current_time; elem.query_start_time = current_time;
elem.query_start_time_microseconds = current_time_microseconds; elem.query_start_time_microseconds = current_time_microseconds;
...@@ -484,6 +485,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl( ...@@ -484,6 +485,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem.type = QueryLogElementType::QUERY_START; elem.type = QueryLogElementType::QUERY_START;
elem.event_time = current_time; elem.event_time = current_time;
elem.event_time_microseconds = current_time_microseconds;
elem.query_start_time = current_time; elem.query_start_time = current_time;
elem.query_start_time_microseconds = current_time_microseconds; elem.query_start_time_microseconds = current_time_microseconds;
...@@ -555,6 +557,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl( ...@@ -555,6 +557,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem.type = QueryLogElementType::QUERY_FINISH; elem.type = QueryLogElementType::QUERY_FINISH;
elem.event_time = time(nullptr); elem.event_time = time(nullptr);
elem.event_time_microseconds = getCurrentTimeMicroseconds();
status_info_to_query_log(elem, info, ast); status_info_to_query_log(elem, info, ast);
...@@ -616,6 +619,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl( ...@@ -616,6 +619,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem.type = QueryLogElementType::EXCEPTION_WHILE_PROCESSING; elem.type = QueryLogElementType::EXCEPTION_WHILE_PROCESSING;
elem.event_time = time(nullptr); elem.event_time = time(nullptr);
elem.event_time_microseconds = getCurrentTimeMicroseconds();
elem.query_duration_ms = 1000 * (elem.event_time - elem.query_start_time); elem.query_duration_ms = 1000 * (elem.event_time - elem.query_start_time);
elem.exception_code = getCurrentExceptionCode(); elem.exception_code = getCurrentExceptionCode();
elem.exception = getCurrentExceptionMessage(false); elem.exception = getCurrentExceptionMessage(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册