appmetrics-dash
appmetrics-dash copied to clipboard
HTTP incoming requests not showing
this is for https://github.com/RuntimeTools/appmetrics/issues/408
only happens when using .attach() method. Seems we need to require appmetics first then pass it into the constructor for the dashboard
var appmetrics = require('appmetrics') var dash = require('appmetrics-dash') var express = require("express"); var app = express(); dash.attach({appmetrics:appmetrics});
docs change required
That's interesting, I would expect it to happen for attach() or monitor() (since attach just calls monitor).
Perhap the difference is between monitor's two modes, the "create an internal express/http Server" mode, and the "replace an http Server's even listeners" mode? Attach only uses the latter, because it attaches to a pre-existing http Server, it doesn't create its own, but the example code uses the "open a second server on a second port" mode.
Also, appmetrics is generally expected to be the first module required, which makes it awkward when its required internally by appmetrics-dash, and appmetrics-dash allows an http server to be injected, which means it supports being called to late, doesn't it?
This is because of how the probes work (they hook into 'require' calls). With monitor we call require('http')
after monitor is called (https://github.com/RuntimeTools/appmetrics-dash/blob/master/lib/appmetrics-dash.js#L115) in order to create our own http server, so yes if you pass your own server into monitor you would see the same problem and would need to work around it in the same way.
@tobespc the docs update needs to also cover calling monitor and passing in a server
Fixed by #72