public interface HttpRequestTracker
NetworkRequestEvent
with AppDynamics Business Transaction Correlation
Usage
Suppose that you have a method like this for making HTTP requests:
public byte[] sendRequest(URL url) throws HttpException { try { // implementation omitted return responseBody; } catch (UnderlyingException e) { throw new HttpException(e); } }Here's how you would augment this method to report requests to the SDK:
public byte[] sendRequest(URL url) throws HttpException { HttpRequestTracker tracker = Instrumentation.beginHttpRequest(url); try { // implementation omitted tracker.withResponseCode(theResponseCode) .withResponseHeaderFields(theResponseHeaderFields) .reportDone(); return responseBody; } catch (UnderlyingException e) { tracker.withThrowable(e) .reportDone(); throw new HttpException(e); } }
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getError()
Gets the error message associated with this request.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getRequestHeaderFields()
Returns the request header fields associated with this request.
|
int |
getResponseCode()
Gets the HTTP status code associated with this request.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getResponseHeaderFields()
Returns the response header fields associated with this request.
|
java.lang.Throwable |
getThrowable()
Gets the throwable associated with this request.
|
void |
reportDone()
Stops tracking an HTTP request.
|
HttpRequestTracker |
withError(java.lang.String error)
Indicates that this request encountered an error.
|
HttpRequestTracker |
withRequestHeaderFields(java.util.Map<java.lang.String,java.util.List<java.lang.String>> requestHeaderFields)
Sets the request headers associated with this request.
|
HttpRequestTracker |
withResponseCode(int responseCode)
Sets the HTTP response code associated with this request.
|
HttpRequestTracker |
withResponseHeaderFields(java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaderFields)
Sets the response headers associated with this request.
|
HttpRequestTracker |
withStatusLine(java.lang.String statusLine)
Sets the HTTP status line associated with this request.
|
HttpRequestTracker |
withThrowable(java.lang.Throwable throwable)
Indicates that this request encountered an error.
|
java.lang.Throwable getThrowable()
HttpRequestTracker withThrowable(java.lang.Throwable throwable)
withError(String)
. If both an error and an throwable
are specified, the error is ignored.throwable
- A throwable describing the error.java.lang.String getError()
HttpRequestTracker withError(java.lang.String error)
error
- A string describing the error.int getResponseCode()
java.lang.NullPointerException
- if withResponseCode(int)
has
never been called to set the value.HttpRequestTracker withResponseCode(int responseCode)
responseCode
- The status code of the response.HttpRequestTracker withStatusLine(java.lang.String statusLine)
statusLine
- Http Statusjava.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaderFields()
HttpRequestTracker withResponseHeaderFields(java.util.Map<java.lang.String,java.util.List<java.lang.String>> responseHeaderFields)
responseHeaderFields
- The headers of the response.java.util.Map<java.lang.String,java.util.List<java.lang.String>> getRequestHeaderFields()
HttpRequestTracker withRequestHeaderFields(java.util.Map<java.lang.String,java.util.List<java.lang.String>> requestHeaderFields)
requestHeaderFields
- The headers of the request.void reportDone()