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>
|
2019-07-24 20:12:32 +00:00
|
|
|
#include <Common/ClickHouseRevision.h>
|
|
|
|
|
2019-02-03 21:30:45 +00:00
|
|
|
|
2019-03-04 13:03:32 +00:00
|
|
|
using namespace DB;
|
|
|
|
|
|
|
|
using TimerDataType = TraceLogElement::TimerDataType;
|
|
|
|
|
|
|
|
const TimerDataType::Values TraceLogElement::timer_values = {
|
|
|
|
{"Real", static_cast<UInt8>(TimerType::Real)},
|
|
|
|
{"CPU", static_cast<UInt8>(TimerType::Cpu)}
|
|
|
|
};
|
2019-02-03 21:30:45 +00:00
|
|
|
|
|
|
|
Block TraceLogElement::createBlock()
|
|
|
|
{
|
|
|
|
return
|
|
|
|
{
|
|
|
|
{std::make_shared<DataTypeDate>(), "event_date"},
|
|
|
|
{std::make_shared<DataTypeDateTime>(), "event_time"},
|
2019-07-24 20:12:32 +00:00
|
|
|
{std::make_shared<DataTypeUInt32>(), "revision"},
|
2019-03-04 13:03:32 +00:00
|
|
|
{std::make_shared<TimerDataType>(timer_values), "timer_type"},
|
2019-07-24 20:10:23 +00:00
|
|
|
{std::make_shared<DataTypeUInt32>(), "thread_number"},
|
2019-02-03 21:30:45 +00:00
|
|
|
{std::make_shared<DataTypeString>(), "query_id"},
|
|
|
|
{std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>()), "trace"}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-07-24 20:10:23 +00:00
|
|
|
void TraceLogElement::appendToBlock(Block & block) const
|
2019-02-03 21:30:45 +00:00
|
|
|
{
|
|
|
|
MutableColumns columns = block.mutateColumns();
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
|
|
|
|
columns[i++]->insert(event_time);
|
2019-07-24 20:12:32 +00:00
|
|
|
columns[i++]->insert(ClickHouseRevision::get());
|
2019-03-04 13:03:32 +00:00
|
|
|
columns[i++]->insert(static_cast<UInt8>(timer_type));
|
2019-07-24 20:10:23 +00:00
|
|
|
columns[i++]->insert(thread_number);
|
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);
|
2019-02-03 21:30:45 +00:00
|
|
|
|
|
|
|
block.setColumns(std::move(columns));
|
|
|
|
}
|