walkinggo commented on code in PR #23811:
URL: https://github.com/apache/pulsar/pull/23811#discussion_r1903130446
##########
pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/JavaInstanceRunnable.java:
##########
@@ -329,26 +334,29 @@ public void run() {
}
}
- JavaExecutionResult result;
// set last invocation time
stats.setLastInvocation(System.currentTimeMillis());
- // start time for process latency stat
- stats.processTimeStart();
-
- // process the message
-
Thread.currentThread().setContextClassLoader(functionClassLoader);
- result = javaInstance.handleMessage(
- currentRecord,
- currentRecord.getValue(),
- asyncResultConsumer,
- asyncErrorHandler);
-
Thread.currentThread().setContextClassLoader(instanceClassLoader);
-
- // register end time
- stats.processTimeEnd();
+ CompletableFuture<InstanceObserver> future =
CompletableFuture.supplyAsync(() -> {
+ JavaExecutionResult result;
+ InstanceObserver instanceObserver = new InstanceObserver();
+ instanceObserver.setStartTime(System.nanoTime());
+ // process the message
+
Thread.currentThread().setContextClassLoader(functionClassLoader);
+ result = javaInstance.handleMessage(
+ currentRecord,
+ currentRecord.getValue(),
+ asyncResultConsumer,
+ asyncErrorHandler);
+
Thread.currentThread().setContextClassLoader(instanceClassLoader);
+ instanceObserver.setJavaExecutionResult(result);
+ return instanceObserver;
+ }).whenComplete((res, ex) -> {
+ stats.processTimeEnd(res.getStartTime());
+ });
+ JavaExecutionResult result =
future.join().getJavaExecutionResult();
Review Comment:
Thank you, I have completed these tasks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]