| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0783ddf commit 19e8876
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ The available categories are: | |||
| 23 | 23 | * `node.console`: Enables capture of `console.time()` and `console.count()` | |
| 24 | 24 | output. | |
| 25 | 25 | * `node.dns.native`: Enables capture of trace data for DNS queries. | |
| 26 | + * `node.net.native`: Enables capture of trace data for network. | ||
| 26 | 27 | * `node.environment`: Enables capture of Node.js Environment milestones. | |
| 27 | 28 | * `node.fs.sync`: Enables capture of trace data for file system sync methods. | |
| 28 | 29 | * `node.perf`: Enables capture of [Performance API][] measurements. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,6 +108,12 @@ void ConnectionWrap<WrapType, UVType>::AfterConnect(uv_connect_t* req, | |||
| 108 | 108 | Boolean::New(env->isolate(), writable) | |
| 109 | 109 | }; | |
| 110 | 110 | ||
| 111 | + TRACE_EVENT_NESTABLE_ASYNC_END1(TRACING_CATEGORY_NODE2(net, native), | ||
| 112 | + "connect", | ||
| 113 | + req_wrap.get(), | ||
| 114 | + "status", | ||
| 115 | + status); | ||
| 116 | + | ||
| 111 | 117 | req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); | |
| 112 | 118 | } | |
| 113 | 119 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,6 +241,12 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) { | |||
| 241 | 241 | *name, | |
| 242 | 242 | AfterConnect); | |
| 243 | 243 | ||
| 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 | + | ||
| 244 | 250 | args.GetReturnValue().Set(0); // uv_pipe_connect() doesn't return errors. | |
| 245 | 251 | } | |
| 246 | 252 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -335,8 +335,18 @@ void TCPWrap::Connect(const FunctionCallbackInfo<Value>& args, | |||
| 335 | 335 | &wrap->handle_, | |
| 336 | 336 | reinterpret_cast<const sockaddr*>(&addr), | |
| 337 | 337 | AfterConnect); | |
| 338 | - if (err) | ||
| 338 | + if (err) { | ||
| 339 | 339 | 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 | + } | ||
| 340 | 350 | } | |
| 341 | 351 | ||
| 342 | 352 | args.GetReturnValue().Set(err); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,45 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const cp = require('child_process'); | ||
| 5 | + const fs = require('fs'); | ||
| 6 | + const path = require('path'); | ||
| 7 | + const tmpdir = require('../common/tmpdir'); | ||
| 8 | + | ||
| 9 | + const CODE = ` | ||
| 10 | + const net = require('net'); | ||
| 11 | + const socket = net.connect('${common.PIPE}'); | ||
| 12 | + socket.on('error', () => {}); | ||
| 13 | + const server = net.createServer((socket) => { | ||
| 14 | + socket.destroy(); | ||
| 15 | + server.close(); | ||
| 16 | + }).listen(0, () => { | ||
| 17 | + net.connect(server.address().port); | ||
| 18 | + }); | ||
| 19 | + `; | ||
| 20 | + | ||
| 21 | + tmpdir.refresh(); | ||
| 22 | + const FILE_NAME = path.join(tmpdir.path, 'node_trace.1.log'); | ||
| 23 | + | ||
| 24 | + const proc = cp.spawn(process.execPath, | ||
| 25 | + [ '--trace-events-enabled', | ||
| 26 | + '--trace-event-categories', 'node.net.native', | ||
| 27 | + '-e', CODE ], | ||
| 28 | + { cwd: tmpdir.path }); | ||
| 29 | + | ||
| 30 | + proc.once('exit', common.mustCall(() => { | ||
| 31 | + assert(fs.existsSync(FILE_NAME)); | ||
| 32 | + fs.readFile(FILE_NAME, common.mustCall((err, data) => { | ||
| 33 | + const traces = JSON.parse(data.toString()).traceEvents; | ||
| 34 | + assert(traces.length > 0); | ||
| 35 | + let count = 0; | ||
| 36 | + traces.forEach((trace) => { | ||
| 37 | + if (trace.cat === 'node,node.net,node.net.native' && | ||
| 38 | + trace.name === 'connect') { | ||
| 39 | + count++; | ||
| 40 | + } | ||
| 41 | + }); | ||
| 42 | + // Two begin, two end | ||
| 43 | + assert.strictEqual(count, 4); | ||
| 44 | + })); | ||
| 45 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments