From 0ebf01dc53b474ffca78c7ace023bb10341b6664 Mon Sep 17 00:00:00 2001 From: vmarchaud Date: Sun, 30 Jun 2019 22:37:18 +0200 Subject: perf_hooks: add HttpRequest statistics monitoring #28445 ```js const { PerformanceObserver, performance } = require('perf_hooks'); const http = require('http'); const obs = new PerformanceObserver((items) => { const entry = items.getEntries()[0]; console.log(entry.name, entry.duration); }); obs.observe({ entryTypes: ['http'] }); const server = http.Server(function(req, res) { server.close(); res.writeHead(200); res.end('hello world\n'); }); server.listen(0, function() { const req = http.request({ port: this.address().port, path: '/', method: 'POST' }).end(); }); ``` PR-URL: https://github.com/nodejs/node/pull/28486 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- lib/perf_hooks.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/perf_hooks.js') diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index e0b7e9d960..14b1aa44dd 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -25,6 +25,7 @@ const { NODE_PERFORMANCE_ENTRY_TYPE_GC, NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION, NODE_PERFORMANCE_ENTRY_TYPE_HTTP2, + NODE_PERFORMANCE_ENTRY_TYPE_HTTP, NODE_PERFORMANCE_MILESTONE_NODE_START, NODE_PERFORMANCE_MILESTONE_V8_START, @@ -70,7 +71,8 @@ const observerableTypes = [ 'measure', 'gc', 'function', - 'http2' + 'http2', + 'http' ]; const IDX_STREAM_STATS_ID = 0; @@ -508,6 +510,7 @@ function mapTypes(i) { case 'gc': return NODE_PERFORMANCE_ENTRY_TYPE_GC; case 'function': return NODE_PERFORMANCE_ENTRY_TYPE_FUNCTION; case 'http2': return NODE_PERFORMANCE_ENTRY_TYPE_HTTP2; + case 'http': return NODE_PERFORMANCE_ENTRY_TYPE_HTTP; } } -- cgit v1.2.3