ClickHouse/src/Common/TraceCollector.h

47 lines
818 B
C++
Raw Normal View History

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;
enum class TraceType : uint8_t
2020-01-16 12:37:29 +00:00
{
Real,
CPU,
Memory,
MemorySample,
MemoryPeak,
2020-01-16 12:37:29 +00:00
};
2019-07-10 20:47:39 +00:00
class TraceCollector
{
2020-01-16 12:37:29 +00:00
public:
TraceCollector(std::shared_ptr<TraceLog> trace_log_);
2020-01-16 12:37:29 +00:00
~TraceCollector();
/// Collect a stack trace. This method is signal safe.
/// Precondition: the TraceCollector object must be created.
/// size - for memory tracing is the amount of memory allocated; for other trace types it is 0.
2020-04-30 13:25:17 +00:00
static void collect(TraceType trace_type, const StackTrace & stack_trace, Int64 size);
2020-01-16 12:37:29 +00:00
2019-07-10 20:47:39 +00:00
private:
std::shared_ptr<TraceLog> trace_log;
ThreadFromGlobalPool thread;
void run();
void stop();
2019-07-10 20:47:39 +00:00
};
}