We want to use NewRelic's noticeNetworkFailure behavior in Mobile to sneakily record exceptions in catch statements that aren't actually network exceptions; because this appears to be the only way for now to track exceptions with NewRelic Mobile.
The following example code doesn't appear to upload any event information, I pondered that it may be because NewRelic recognizes that the exception isn't a network exception and ignores the call.
long time = System.currentTimeMillis();
NewRelic.noticeNetworkFailure("HomeFragment.updateUi.IllegalStateException", time, time, new IllegalStateException());
The URL value is just a string we craft with classname.method(or subclass then method).exceptionType it allows identification of the related code and will theoretically group the exceptions under a common URL in NewRelic.
Has anyone done this before or knows what if anything I can do to achieve this?
NB: NewRelic is working perfectly in all other regards it's traces and other reporting is working well.
Update #1: Still appears to be failing URL validation? I trigger a number of notices using the coding below and still get the Harvester sending 0 HTTP errors.
NewRelic.noticeNetworkFailure("http://exception.com/HomeFragment/updateUi/IllegalStateException", time, time+1, new IllegalStateException());
Unfortunately, this is not going to work without further sneakiness. Network errors aren't considered HTTP errors and will be grouped with HTTP transactions. Instead, use NewRelic.noticeHttpTransaction like so:
If you add
http://exception/...
in front of the string, you'll pass the validation (although mind the characters in your string) and the error will show up on newrelic.com on the HTTP errors page. Addingexception
at the beginning will group these errors for easier reading. However, be warned that you'll be mixing these errors up with 'real' ones generated by your app.Always good to hear New Relic is working well for you, thanks!