Description
Is your feature request related to a problem? Please describe.
Retrieve metrics from a HTTP server.
Describe the solution you'd like
Pretty much the same as the current implementation between http2
and perf_hooks
: https://github.com/nodejs/node/blob/master/test/parallel/test-http2-perf_hooks.js
Since the http
server is only js-land, i believe we could just implement by hooking to the perf_hooks
js api.
I've looked a little bit at the code, we could add a stats object in the request state and emit them when the request is ended (of course only if the entry has an observer).
I'm really interested on implementing it so i'm opening it an issue to have some feedback before coding anything.
Describe alternatives you've considered
Currently i believe all APM vendors are forced to monkey-patch the event-emitter on http.Server.prototype
and then listen on request event, add event listener to know when the response is sent and compute some metrics about both the request and the response.