2019-02-03 21:30:45 +00:00
|
|
|
#include <Interpreters/TraceLog.h>
|
|
|
|
#include <DataTypes/DataTypeArray.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataTypes/DataTypeDate.h>
|
|
|
|
#include <DataTypes/DataTypeDateTime.h>
|
2020-09-10 06:36:32 +00:00
|
|
|
#include <DataTypes/DataTypeDateTime64.h>
|
2019-07-24 20:12:32 +00:00
|
|
|
#include <Common/ClickHouseRevision.h>
|
|
|
|
|
2019-02-03 21:30:45 +00:00
|
|
|
|
2020-07-09 04:15:45 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2019-03-04 13:03:32 +00:00
|
|
|
|
2020-01-15 10:51:51 +00:00
|
|
|
using TraceDataType = TraceLogElement::TraceDataType;
|
2019-03-04 13:03:32 +00:00
|
|
|
|
2020-03-03 00:28:52 +00:00
|
|
|
const TraceDataType::Values TraceLogElement::trace_values =
|
|
|
|
{
|
|
|
|
{"Real", static_cast<UInt8>(TraceType::Real)},
|
|
|
|
{"CPU", static_cast<UInt8>(TraceType::CPU)},
|
|
|
|
{"Memory", static_cast<UInt8>(TraceType::Memory)},
|
2020-04-30 13:25:17 +00:00
|
|
|
{"MemorySample", static_cast<UInt8>(TraceType::MemorySample)},
|
2019-03-04 13:03:32 +00:00
|
|
|
};
|
2019-02-03 21:30:45 +00:00
|
|
|
|
2021-06-28 11:42:21 +00:00
|
|
|
NamesAndTypesList TraceLogElement::getNamesAndTypes()
|
2019-02-03 21:30:45 +00:00
|
|
|
{
|
|
|
|
return
|
|
|
|
{
|
2021-06-28 11:42:21 +00:00
|
|
|
{"event_date", std::make_shared<DataTypeDate>()},
|
|
|
|
{"event_time", std::make_shared<DataTypeDateTime>()},
|
|
|
|
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
|
|
|
{"timestamp_ns", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"revision", std::make_shared<DataTypeUInt32>()},
|
|
|
|
{"trace_type", std::make_shared<TraceDataType>(trace_values)},
|
|
|
|
{"thread_id", std::make_shared<DataTypeUInt64>()},
|
|
|
|
{"query_id", std::make_shared<DataTypeString>()},
|
|
|
|
{"trace", std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>())},
|
|
|
|
{"size", std::make_shared<DataTypeInt64>()},
|
2019-02-03 21:30:45 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-05-21 20:15:18 +00:00
|
|
|
void TraceLogElement::appendToBlock(MutableColumns & columns) const
|
2019-02-03 21:30:45 +00:00
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
|
2020-04-17 13:26:44 +00:00
|
|
|
columns[i++]->insert(DateLUT::instance().toDayNum(event_time).toUnderType());
|
2019-02-03 21:30:45 +00:00
|
|
|
columns[i++]->insert(event_time);
|
2020-09-10 06:36:32 +00:00
|
|
|
columns[i++]->insert(event_time_microseconds);
|
2020-03-17 02:15:05 +00:00
|
|
|
columns[i++]->insert(timestamp_ns);
|
2020-09-17 12:15:05 +00:00
|
|
|
columns[i++]->insert(ClickHouseRevision::getVersionRevision());
|
2020-01-15 10:51:51 +00:00
|
|
|
columns[i++]->insert(static_cast<UInt8>(trace_type));
|
2020-02-02 02:27:15 +00:00
|
|
|
columns[i++]->insert(thread_id);
|
2019-02-03 21:30:45 +00:00
|
|
|
columns[i++]->insertData(query_id.data(), query_id.size());
|
2019-07-05 13:48:47 +00:00
|
|
|
columns[i++]->insert(trace);
|
2020-01-16 12:37:29 +00:00
|
|
|
columns[i++]->insert(size);
|
2019-02-03 21:30:45 +00:00
|
|
|
}
|
2020-07-09 04:15:45 +00:00
|
|
|
|
|
|
|
}
|