ClickHouse/src/Interpreters/TraceLog.cpp

52 lines
2.0 KiB
C++
Raw Normal View History

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>
#include <Common/ClickHouseRevision.h>
2019-02-03 21:30:45 +00:00
using namespace DB;
using TraceDataType = TraceLogElement::TraceDataType;
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-02-03 21:30:45 +00:00
Block TraceLogElement::createBlock()
{
return
{
{std::make_shared<DataTypeDate>(), "event_date"},
{std::make_shared<DataTypeDateTime>(), "event_time"},
{std::make_shared<DataTypeUInt64>(), "timestamp_ns"},
{std::make_shared<DataTypeUInt32>(), "revision"},
{std::make_shared<TraceDataType>(trace_values), "trace_type"},
2020-02-10 15:24:26 +00:00
{std::make_shared<DataTypeUInt64>(), "thread_id"},
2019-02-03 21:30:45 +00:00
{std::make_shared<DataTypeString>(), "query_id"},
2020-01-16 12:37:29 +00:00
{std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>()), "trace"},
2020-04-30 13:25:17 +00:00
{std::make_shared<DataTypeInt64>(), "size"},
2019-02-03 21:30:45 +00:00
};
}
void TraceLogElement::appendToBlock(MutableColumns & columns) const
2019-02-03 21:30:45 +00:00
{
size_t i = 0;
columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
columns[i++]->insert(event_time);
columns[i++]->insert(timestamp_ns);
columns[i++]->insert(ClickHouseRevision::get());
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
}