Syntax
NewRelic.noticeNetworkFailure(string $url, string $httpMethod, long $startTime, long $endTime, exception $exception OR enum $networkFailure)
Records network failures.
Requirements
Compatible with agent versions 6.9.0 and below.
Important
As of New Relic Android agent version 6.9.2, the noticeNetworkFailure
method is deprecated. The noticeNetworkFailure
method will continue to work on versions 6.9.0 and below, but if your app contains noticeNetworkFailure
methods, New Relic recommends you replace them with noticeHttpTransaction.
Description
The New Relic Android SDK API provides several methods to track network requests. If a network request fails, you can record details about the failure with noticeNetworkFailure
. In most cases, place this call inside exception handlers, such as catch blocks.
For general info on using the New Relic Android SDK API, see the usage guide.
Parameters
Parameter | Description |
---|---|
| |
string | Required. The URL of the request. |
string | Required. The HTTP method used, such as GET or POST. |
long | Required. The start time of the request in milliseconds since the epoch. |
long | Required. The end time of the request in milliseconds since the epoch. |
string | Either this or |
enum | Either this or |
Examples
Record network failure
Here’s an example of an error listener that uses an error as part of the noticed network failure to New Relic:
new Response.ErrorListener() { @Override public void onErrorResponse(Error error) { NewRelic.noticeNetworkFailure(badUrl, "GET", System.nanoTime(), System.nanoTime(), NetworkFailure.exceptionToNetworkFailure(error)); }