mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Add new trace type to system.trace_log table
This commit is contained in:
parent
e96021cefe
commit
c566f406c5
@ -34,7 +34,7 @@ namespace
|
||||
thread_local size_t write_trace_iteration = 0;
|
||||
#endif
|
||||
|
||||
void writeTraceInfo(TimerType timer_type, int /* sig */, siginfo_t * info, void * context)
|
||||
void writeTraceInfo(TraceType trace_type, int /* sig */, siginfo_t * info, void * context)
|
||||
{
|
||||
#if defined(OS_LINUX)
|
||||
/// Quickly drop if signal handler is called too frequently.
|
||||
@ -62,7 +62,7 @@ namespace
|
||||
QUERY_ID_MAX_LEN * sizeof(char) + // maximum query_id length
|
||||
sizeof(UInt8) + // number of stack frames
|
||||
sizeof(StackTrace::Frames) + // collected stack trace, maximum capacity
|
||||
sizeof(TimerType) + // timer type
|
||||
sizeof(TraceType) + // timer type
|
||||
sizeof(UInt32); // thread_number
|
||||
char buffer[buf_size];
|
||||
WriteBufferFromFileDescriptorDiscardOnFailure out(trace_pipe.fds_rw[1], buf_size, buffer);
|
||||
@ -84,7 +84,7 @@ namespace
|
||||
for (size_t i = stack_trace_offset; i < stack_trace_size; ++i)
|
||||
writePODBinary(stack_trace.getFrames()[i], out);
|
||||
|
||||
writePODBinary(timer_type, out);
|
||||
writePODBinary(trace_type, out);
|
||||
writePODBinary(thread_number, out);
|
||||
out.next();
|
||||
}
|
||||
@ -198,7 +198,7 @@ QueryProfilerReal::QueryProfilerReal(const Int32 thread_id, const UInt32 period)
|
||||
|
||||
void QueryProfilerReal::signalHandler(int sig, siginfo_t * info, void * context)
|
||||
{
|
||||
writeTraceInfo(TimerType::Real, sig, info, context);
|
||||
writeTraceInfo(TraceType::REAL_TIME, sig, info, context);
|
||||
}
|
||||
|
||||
QueryProfilerCpu::QueryProfilerCpu(const Int32 thread_id, const UInt32 period)
|
||||
@ -207,7 +207,7 @@ QueryProfilerCpu::QueryProfilerCpu(const Int32 thread_id, const UInt32 period)
|
||||
|
||||
void QueryProfilerCpu::signalHandler(int sig, siginfo_t * info, void * context)
|
||||
{
|
||||
writeTraceInfo(TimerType::Cpu, sig, info, context);
|
||||
writeTraceInfo(TraceType::CPU_TIME, sig, info, context);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ namespace Poco
|
||||
namespace DB
|
||||
{
|
||||
|
||||
enum class TimerType : UInt8
|
||||
enum class TraceType : UInt8
|
||||
{
|
||||
Real,
|
||||
Cpu,
|
||||
REAL_TIME,
|
||||
CPU_TIME,
|
||||
MEMORY,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -102,13 +102,13 @@ void TraceCollector::run()
|
||||
trace.emplace_back(UInt64(addr));
|
||||
}
|
||||
|
||||
TimerType timer_type;
|
||||
readPODBinary(timer_type, in);
|
||||
TraceType trace_type;
|
||||
readPODBinary(trace_type, in);
|
||||
|
||||
UInt32 thread_number;
|
||||
readPODBinary(thread_number, in);
|
||||
|
||||
TraceLogElement element{std::time(nullptr), timer_type, thread_number, query_id, trace};
|
||||
TraceLogElement element{std::time(nullptr), trace_type, thread_number, query_id, trace};
|
||||
trace_log->add(element);
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,12 @@
|
||||
|
||||
using namespace DB;
|
||||
|
||||
using TimerDataType = TraceLogElement::TimerDataType;
|
||||
using TraceDataType = TraceLogElement::TraceDataType;
|
||||
|
||||
const TimerDataType::Values TraceLogElement::timer_values = {
|
||||
{"Real", static_cast<UInt8>(TimerType::Real)},
|
||||
{"CPU", static_cast<UInt8>(TimerType::Cpu)}
|
||||
const TraceDataType::Values TraceLogElement::trace_values = {
|
||||
{"Real", static_cast<UInt8>(TraceType::REAL_TIME)},
|
||||
{"CPU", static_cast<UInt8>(TraceType::CPU_TIME)},
|
||||
{"Memory", static_cast<UInt8>(TraceType::MEMORY)},
|
||||
};
|
||||
|
||||
Block TraceLogElement::createBlock()
|
||||
@ -23,7 +24,7 @@ Block TraceLogElement::createBlock()
|
||||
{std::make_shared<DataTypeDate>(), "event_date"},
|
||||
{std::make_shared<DataTypeDateTime>(), "event_time"},
|
||||
{std::make_shared<DataTypeUInt32>(), "revision"},
|
||||
{std::make_shared<TimerDataType>(timer_values), "timer_type"},
|
||||
{std::make_shared<TraceDataType>(trace_values), "trace_type"},
|
||||
{std::make_shared<DataTypeUInt32>(), "thread_number"},
|
||||
{std::make_shared<DataTypeString>(), "query_id"},
|
||||
{std::make_shared<DataTypeArray>(std::make_shared<DataTypeUInt64>()), "trace"}
|
||||
@ -39,7 +40,7 @@ void TraceLogElement::appendToBlock(Block & block) const
|
||||
columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
|
||||
columns[i++]->insert(event_time);
|
||||
columns[i++]->insert(ClickHouseRevision::get());
|
||||
columns[i++]->insert(static_cast<UInt8>(timer_type));
|
||||
columns[i++]->insert(static_cast<UInt8>(trace_type));
|
||||
columns[i++]->insert(thread_number);
|
||||
columns[i++]->insertData(query_id.data(), query_id.size());
|
||||
columns[i++]->insert(trace);
|
||||
|
@ -10,14 +10,14 @@ namespace DB
|
||||
|
||||
struct TraceLogElement
|
||||
{
|
||||
using TimerDataType = DataTypeEnum8;
|
||||
static const TimerDataType::Values timer_values;
|
||||
using TraceDataType = DataTypeEnum8;
|
||||
static const TraceDataType::Values trace_values;
|
||||
|
||||
time_t event_time{};
|
||||
TimerType timer_type{};
|
||||
UInt32 thread_number{};
|
||||
String query_id{};
|
||||
Array trace{};
|
||||
time_t event_time;
|
||||
TraceType trace_type;
|
||||
UInt32 thread_number;
|
||||
String query_id;
|
||||
Array trace;
|
||||
|
||||
static std::string name() { return "TraceLog"; }
|
||||
static Block createBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user