mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
TraceLog - add field event_time_microseconds
This commit is contained in:
parent
69e0d59c64
commit
b0d4fe5114
@ -13,6 +13,12 @@ inline UInt64 clock_gettime_ns(clockid_t clock_type = CLOCK_MONOTONIC)
|
||||
return UInt64(ts.tv_sec * 1000000000LL + ts.tv_nsec);
|
||||
}
|
||||
|
||||
inline UInt64 clock_gettime_microseconds(clockid_t clock_type = CLOCK_MONOTONIC)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(clock_type, &ts);
|
||||
return UInt64((ts.tv_sec * 1000000LL) + (ts.tv_nsec / 1000));
|
||||
}
|
||||
|
||||
/** Differs from Poco::Stopwatch only by using 'clock_gettime' instead of 'gettimeofday',
|
||||
* returns nanoseconds instead of microseconds, and also by other minor differencies.
|
||||
|
@ -142,7 +142,8 @@ void TraceCollector::run()
|
||||
if (trace_log)
|
||||
{
|
||||
UInt64 time = clock_gettime_ns(CLOCK_REALTIME);
|
||||
TraceLogElement element{time_t(time / 1000000000), time, trace_type, thread_id, query_id, trace, size};
|
||||
UInt64 time_in_microseconds = clock_gettime_microseconds(CLOCK_REALTIME);
|
||||
TraceLogElement element{time_t(time / 1000000000), time_in_microseconds, time, trace_type, thread_id, query_id, trace, size};
|
||||
trace_log->add(element);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <DataTypes/DataTypeDate.h>
|
||||
#include <DataTypes/DataTypeDateTime.h>
|
||||
#include <DataTypes/DataTypeDateTime64.h>
|
||||
#include <Common/ClickHouseRevision.h>
|
||||
|
||||
|
||||
@ -26,6 +27,7 @@ Block TraceLogElement::createBlock()
|
||||
{
|
||||
{std::make_shared<DataTypeDate>(), "event_date"},
|
||||
{std::make_shared<DataTypeDateTime>(), "event_time"},
|
||||
{std::make_shared<DataTypeDateTime64>(6), "event_time_microseconds"},
|
||||
{std::make_shared<DataTypeUInt64>(), "timestamp_ns"},
|
||||
{std::make_shared<DataTypeUInt32>(), "revision"},
|
||||
{std::make_shared<TraceDataType>(trace_values), "trace_type"},
|
||||
@ -42,6 +44,7 @@ void TraceLogElement::appendToBlock(MutableColumns & columns) const
|
||||
|
||||
columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
|
||||
columns[i++]->insert(event_time);
|
||||
columns[i++]->insert(event_time_microseconds);
|
||||
columns[i++]->insert(timestamp_ns);
|
||||
columns[i++]->insert(ClickHouseRevision::getVersionRevision());
|
||||
columns[i++]->insert(static_cast<UInt8>(trace_type));
|
||||
|
@ -18,6 +18,7 @@ struct TraceLogElement
|
||||
static const TraceDataType::Values trace_values;
|
||||
|
||||
time_t event_time{};
|
||||
UInt64 event_time_microseconds{};
|
||||
UInt64 timestamp_ns{};
|
||||
TraceType trace_type{};
|
||||
UInt64 thread_id{};
|
||||
|
Loading…
Reference in New Issue
Block a user