diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java index 0116d600e6..6900d3cbab 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java @@ -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()); diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/InvokeHTTPTest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/InvokeHTTPTest.java index 387c2e8a5a..ab4156d14f 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/InvokeHTTPTest.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/InvokeHTTPTest.java @@ -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); }