blob: ca5fd35417fd0f08c2aa2ce2ee661a12da9eef5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#ifndef SRC_TRACING_AGENT_H_
#define SRC_TRACING_AGENT_H_
#include "libplatform/v8-tracing.h"
#include "uv.h"
#include "v8.h"
#include <set>
#include <string>
namespace node {
namespace tracing {
using v8::platform::tracing::TraceConfig;
class TracingController : public v8::platform::tracing::TracingController {
public:
TracingController() : v8::platform::tracing::TracingController() {}
int64_t CurrentTimestampMicroseconds() override {
return uv_hrtime() / 1000;
}
};
class Agent {
public:
explicit Agent(const std::string& log_file_pattern);
void Stop();
TracingController* GetTracingController() { return tracing_controller_; }
void Enable(const std::string& categories);
void Enable(const std::set<std::string>& categories);
void Disable(const std::set<std::string>& categories);
std::string GetEnabledCategories();
private:
static void ThreadCb(void* arg);
void Start();
void RestartTracing();
TraceConfig* CreateTraceConfig();
const std::string& log_file_pattern_;
uv_thread_t thread_;
uv_loop_t tracing_loop_;
bool started_ = false;
std::multiset<std::string> categories_;
TracingController* tracing_controller_ = nullptr;
};
} // namespace tracing
} // namespace node
#endif // SRC_TRACING_AGENT_H_
|