mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
src: refactor tracing agent code
Avoid unnecessary operations, add a bit of documentation, and turn the `ClientHandle` smart pointer alias into a real class. This should allow de-coupling the unnecessary combination of a single specific `file_writer` from `Agent`. PR-URL: https://github.com/nodejs/node/pull/21867 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
This commit is contained in:
1 parent
4379140dbf
commit
daafe6c195
5 files changed
+87
-58
No files matched your search
+6
-4
@@ -387,7 +387,7 @@ class NodeTraceStateObserver :
|
||||
static struct {
|
||||
#if NODE_USE_V8_PLATFORM
|
||||
void Initialize(int thread_pool_size) {
|
||||
tracing_agent_.reset(new tracing::Agent(trace_file_pattern));
|
||||
tracing_agent_.reset(new tracing::Agent());
|
||||
auto controller = tracing_agent_->GetTracingController();
|
||||
controller->AddTraceStateObserver(new NodeTraceStateObserver(controller));
|
||||
tracing::TraceEventHelper::SetTracingController(controller);
|
||||
@@ -427,12 +427,13 @@ static struct {
|
||||
#endif // HAVE_INSPECTOR
|
||||
|
||||
void StartTracingAgent() {
|
||||
tracing_agent_->Enable(trace_enabled_categories);
|
||||
tracing_file_writer_ = tracing_agent_->AddClient(
|
||||
trace_enabled_categories,
|
||||
new tracing::NodeTraceWriter(trace_file_pattern));
|
||||
}
|
||||
|
||||
void StopTracingAgent() {
|
||||
if (tracing_agent_)
|
||||
tracing_agent_->Stop();
|
||||
tracing_file_writer_.reset();
|
||||
}
|
||||
|
||||
tracing::Agent* GetTracingAgent() const {
|
||||
@@ -444,6 +445,7 @@ static struct {
|
||||
}
|
||||
|
||||
std::unique_ptr<tracing::Agent> tracing_agent_;
|
||||
tracing::AgentWriterHandle tracing_file_writer_;
|
||||
NodePlatform* platform_;
|
||||
#else // !NODE_USE_V8_PLATFORM
|
||||
void Initialize(int thread_pool_size) {}
|
||||
|
||||
Reference in new issue
Block a user