mirror of https://github.com/apache/nifi.git
NIFI-9349 - add attribute with request duration in InvokeHTTP (#5501)
This closes #9349 Signed-off-by: Otto Fowler <ottobackwards@gmail.com>
This commit is contained in:
parent
362a243e0f
commit
decfad394d
|
@ -119,6 +119,7 @@ import static org.apache.commons.lang3.StringUtils.trimToEmpty;
|
|||
@WritesAttribute(attribute = InvokeHTTP.RESPONSE_BODY, description = "In the instance where the status code received is not a success (2xx) "
|
||||
+ "then the response body will be put to the 'invokehttp.response.body' attribute of the request FlowFile."),
|
||||
@WritesAttribute(attribute = InvokeHTTP.REQUEST_URL, description = "The original request URL"),
|
||||
@WritesAttribute(attribute = InvokeHTTP.REQUEST_DURATION, description = "Duration (in milliseconds) of the HTTP call to the external endpoint"),
|
||||
@WritesAttribute(attribute = InvokeHTTP.RESPONSE_URL, description = "The URL that was ultimately requested after any redirects were followed"),
|
||||
@WritesAttribute(attribute = InvokeHTTP.TRANSACTION_ID, description = "The transaction ID that is returned after reading the response"),
|
||||
@WritesAttribute(attribute = InvokeHTTP.REMOTE_DN, description = "The DN of the remote server"),
|
||||
|
@ -142,6 +143,7 @@ public class InvokeHTTP extends AbstractProcessor {
|
|||
public final static String STATUS_MESSAGE = "invokehttp.status.message";
|
||||
public final static String RESPONSE_BODY = "invokehttp.response.body";
|
||||
public final static String REQUEST_URL = "invokehttp.request.url";
|
||||
public final static String REQUEST_DURATION = "invokehttp.request.duration";
|
||||
public final static String RESPONSE_URL = "invokehttp.response.url";
|
||||
public final static String TRANSACTION_ID = "invokehttp.tx.id";
|
||||
public final static String REMOTE_DN = "invokehttp.remote.dn";
|
||||
|
@ -860,6 +862,7 @@ public class InvokeHTTP extends AbstractProcessor {
|
|||
statusAttributes.put(STATUS_CODE, String.valueOf(statusCode));
|
||||
statusAttributes.put(STATUS_MESSAGE, statusMessage);
|
||||
statusAttributes.put(REQUEST_URL, url.toExternalForm());
|
||||
statusAttributes.put(REQUEST_DURATION, Long.toString(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos)));
|
||||
statusAttributes.put(RESPONSE_URL, responseHttp.request().url().toString());
|
||||
statusAttributes.put(TRANSACTION_ID, txId.toString());
|
||||
|
||||
|
|
|
@ -781,6 +781,7 @@ public class InvokeHTTPTest {
|
|||
flowFile.assertAttributeExists(InvokeHTTP.STATUS_MESSAGE);
|
||||
flowFile.assertAttributeExists(InvokeHTTP.TRANSACTION_ID);
|
||||
flowFile.assertAttributeExists(InvokeHTTP.REQUEST_URL);
|
||||
flowFile.assertAttributeExists(InvokeHTTP.REQUEST_DURATION);
|
||||
flowFile.assertAttributeExists(InvokeHTTP.RESPONSE_URL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue