2019-07-10 20:47:39 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-01-16 12:37:29 +00:00
|
|
|
#include "Common/PipeFDs.h"
|
2019-07-10 20:47:39 +00:00
|
|
|
#include <Common/ThreadPool.h>
|
|
|
|
|
2020-01-16 12:37:29 +00:00
|
|
|
class StackTrace;
|
|
|
|
|
2019-07-10 20:47:39 +00:00
|
|
|
namespace Poco
|
|
|
|
{
|
|
|
|
class Logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class TraceLog;
|
|
|
|
|
2020-01-16 12:37:29 +00:00
|
|
|
enum class TraceType : UInt8
|
|
|
|
{
|
|
|
|
REAL_TIME,
|
|
|
|
CPU_TIME,
|
|
|
|
MEMORY,
|
|
|
|
};
|
|
|
|
|
2019-07-10 20:47:39 +00:00
|
|
|
class TraceCollector
|
|
|
|
{
|
2020-01-16 12:37:29 +00:00
|
|
|
public:
|
|
|
|
TraceCollector();
|
|
|
|
~TraceCollector();
|
|
|
|
|
|
|
|
void setTraceLog(const std::shared_ptr<TraceLog> & trace_log_) { trace_log = trace_log_; }
|
|
|
|
|
|
|
|
void collect(TraceType type, const StackTrace & stack_trace, int overrun_count = 0);
|
|
|
|
void collect(UInt64 size);
|
|
|
|
|
2019-07-10 20:47:39 +00:00
|
|
|
private:
|
|
|
|
std::shared_ptr<TraceLog> trace_log;
|
|
|
|
ThreadFromGlobalPool thread;
|
2020-01-16 12:37:29 +00:00
|
|
|
LazyPipeFDs pipe;
|
2019-07-10 20:47:39 +00:00
|
|
|
|
|
|
|
void run();
|
2020-02-11 15:16:53 +00:00
|
|
|
void stop();
|
2019-07-10 20:47:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|