How do you get a new relic for recording errors that lead to a process crash using New Relic application monitoring? The key models I'm trying to execute is the presence of errors that cause the process to crash, are still logged , and somehow filter these errors on the dashboard .
Here is my understanding so far:
A new relic transfers data to its clouds every minute. In the event of uncaughtException
this will cause all data pending transmission to be lost.
There is newrelic.noticeError()
, which should take a second argument, allowing you to pass user parameters with an error. A new relic receives an error, but not user parameters.
A simple example:
var newrelic = require("newrelic"); var express = require("express"); var app = express(); app.get("/softFail/", function(req, res) { res.send(500, "softFail"); }); app.get("/hardFail/", function(req, res) { setImmediate(function() { throw new Error("I failed"); }); }); app.listen(80); process.on("uncaughtException", function(err) { console.error("Uncaught Exception"); console.error(err.stack); newrelic.addCustomParameter("crash", "true"); newrelic.noticeError(err); console.log("sending errors to New Relic"); newrelic.agent.harvest(function() { console.log("send complete, crashing process"); process.exit(1); }); });
Using this block of code, if I call / hardFail /, I can get New Relic to at least log the error. Without the uncaughtException
handler uncaughtException
I get nothing from New Relic. The problem is that I cannot distinguish between errors that cause the process to fail and regular HTTP 500 errors.
Here's something I've tried:
If I try to add { crash : true }
to the noticeError
call, this does not seem to affect.
I tried to make domain
instead of process.on
, which did not change the situation.
If I try to change the name
error, for example err.name = "CrashError"
, then the error is not transmitted at all.
If I create my own type of error, and then a new one, which copies the stack trace, it will still be displayed as the Error
type, not prototype.name
my new error type.
source share