From 997531193b27e312cf8ca8c142019599b9dafdd8 Mon Sep 17 00:00:00 2001 From: vmarchaud Date: Sun, 30 Jun 2019 22:37:18 +0200 Subject: [PATCH] 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 --- doc/api/perf_hooks.md | 2 +- lib/_http_server.js | 20 ++++++++- lib/internal/http.js | 20 ++++++++- lib/perf_hooks.js | 5 ++- src/node_perf.cc | 16 ++++++++ src/node_perf_common.h | 3 +- test/parallel/test-http-perf_hooks.js | 58 +++++++++++++++++++++++++++ 7 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 test/parallel/test-http-perf_hooks.js diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index ce72ba680aebd9..c143b161a3ff10 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -183,7 +183,7 @@ added: v8.5.0 * {string} The type of the performance entry. Currently it may be one of: `'node'`, -`'mark'`, `'measure'`, `'gc'`, `'function'`, or `'http2'`. +`'mark'`, `'measure'`, `'gc'`, `'function'`, `'http2'` or `'http'`. ### performanceEntry.kind