trace_events: trace net connect event · nodejs/node@19e8876 · GitHub
Skip to content

Commit 19e8876

Browse files
theanarkhdanielleadams
authored andcommitted
trace_events: trace net connect event
PR-URL: #43903 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent 0783ddf commit 19e8876

5 files changed

Lines changed: 69 additions & 1 deletion

File tree

doc/api/tracing.md

Lines changed: 1 addition & 0 deletions

src/connection_wrap.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ void ConnectionWrap<WrapType, UVType>::AfterConnect(uv_connect_t* req,
108108
Boolean::New(env->isolate(), writable)
109109
};
110110

111+
TRACE_EVENT_NESTABLE_ASYNC_END1(TRACING_CATEGORY_NODE2(net, native),
112+
"connect",
113+
req_wrap.get(),
114+
"status",
115+
status);
116+
111117
req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv);
112118
}
113119

src/pipe_wrap.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
241241
*name,
242242
AfterConnect);
243243

244+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
245+
"connect",
246+
req_wrap,
247+
"pipe_path",
248+
TRACE_STR_COPY(*name));
249+
244250
args.GetReturnValue().Set(0); // uv_pipe_connect() doesn't return errors.
245251
}
246252

src/tcp_wrap.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,18 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args,
335335
&wrap->handle_,
336336
reinterpret_cast<const sockaddr*>(&addr),
337337
AfterConnect);
338-
if (err)
338+
if (err) {
339339
delete req_wrap;
340+
} else {
341+
int port = args[2]->Uint32Value(env->context()).FromJust();
342+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(TRACING_CATEGORY_NODE2(net, native),
343+
"connect",
344+
req_wrap,
345+
"ip",
346+
TRACE_STR_COPY(*ip_address),
347+
"port",
348+
port);
349+
}
340350
}
341351

342352
args.GetReturnValue().Set(err);
Lines changed: 45 additions & 0 deletions

0 commit comments

Comments
 (0)