From 4672549ef76dcb83303b06812b5c909534df2683 Mon Sep 17 00:00:00 2001 From: Shreyas Gopalakrishna <11889130+shreyas-gopalakrishna@users.noreply.github.com> Date: Mon, 15 Aug 2022 12:37:10 -0500 Subject: [PATCH] Adding logs for easier debugging (#615) --- src/main/java/com/microsoft/azure/functions/worker/Util.java | 4 ++++ .../handler/FunctionEnvironmentReloadRequestHandler.java | 1 + .../functions/worker/handler/FunctionLoadRequestHandler.java | 3 +++ .../functions/worker/handler/InvocationRequestHandler.java | 4 ++++ .../functions/worker/handler/WorkerInitRequestHandler.java | 3 +++ 5 files changed, 15 insertions(+) diff --git a/src/main/java/com/microsoft/azure/functions/worker/Util.java b/src/main/java/com/microsoft/azure/functions/worker/Util.java index 67185e39..2b083ed3 100644 --- a/src/main/java/com/microsoft/azure/functions/worker/Util.java +++ b/src/main/java/com/microsoft/azure/functions/worker/Util.java @@ -7,4 +7,8 @@ public static boolean isTrue(String value) { } return false; } + + public static String getJavaVersion() { + return String.join(" - ", System.getProperty("java.home"), System.getProperty("java.version")); + } } \ No newline at end of file diff --git a/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionEnvironmentReloadRequestHandler.java b/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionEnvironmentReloadRequestHandler.java index 21e94b82..5f9513ad 100644 --- a/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionEnvironmentReloadRequestHandler.java +++ b/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionEnvironmentReloadRequestHandler.java @@ -25,6 +25,7 @@ public FunctionEnvironmentReloadRequestHandler(JavaFunctionBroker broker) { @Override String execute(FunctionEnvironmentReloadRequest request, Builder response) throws Exception { + WorkerLogManager.getSystemLogger().log(Level.INFO, "FunctionEnvironmentReloadRequest received by the Java worker"); EnvironmentVariables = request.getEnvironmentVariablesMap(); if (EnvironmentVariables == null || EnvironmentVariables.isEmpty()) { return String diff --git a/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionLoadRequestHandler.java b/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionLoadRequestHandler.java index f21c7003..4ff04c64 100644 --- a/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionLoadRequestHandler.java +++ b/src/main/java/com/microsoft/azure/functions/worker/handler/FunctionLoadRequestHandler.java @@ -1,7 +1,9 @@ package com.microsoft.azure.functions.worker.handler; import java.util.*; +import java.util.logging.Level; +import com.microsoft.azure.functions.worker.WorkerLogManager; import com.microsoft.azure.functions.worker.broker.*; import com.microsoft.azure.functions.worker.description.*; import com.microsoft.azure.functions.rpc.messages.*; @@ -18,6 +20,7 @@ public FunctionLoadRequestHandler(JavaFunctionBroker broker) { @Override String execute(FunctionLoadRequest request, FunctionLoadResponse.Builder response) throws Exception { + WorkerLogManager.getSystemLogger().log(Level.INFO, "FunctionLoadRequest received by the Java worker"); final RpcFunctionMetadata metadata = request.getMetadata(); final FunctionMethodDescriptor descriptor = createFunctionDescriptor(request.getFunctionId(), metadata); diff --git a/src/main/java/com/microsoft/azure/functions/worker/handler/InvocationRequestHandler.java b/src/main/java/com/microsoft/azure/functions/worker/handler/InvocationRequestHandler.java index cf61b61a..e46ff66a 100644 --- a/src/main/java/com/microsoft/azure/functions/worker/handler/InvocationRequestHandler.java +++ b/src/main/java/com/microsoft/azure/functions/worker/handler/InvocationRequestHandler.java @@ -7,6 +7,8 @@ import com.microsoft.azure.functions.worker.broker.*; import com.microsoft.azure.functions.rpc.messages.*; +import static com.microsoft.azure.functions.worker.Util.getJavaVersion; + public class InvocationRequestHandler extends MessageHandler { public InvocationRequestHandler(JavaFunctionBroker broker) { super(StreamingMessage::getInvocationRequest, @@ -23,6 +25,8 @@ public InvocationRequestHandler(JavaFunctionBroker broker) { @Override String execute(InvocationRequest request, InvocationResponse.Builder response) throws Exception { + WorkerLogManager.getSystemLogger().log(Level.INFO, "Java version - " + getJavaVersion()); + WorkerLogManager.getSystemLogger().log(Level.INFO, "InvocationRequest received by the Java worker"); final String functionId = request.getFunctionId(); final String invocationId = request.getInvocationId(); diff --git a/src/main/java/com/microsoft/azure/functions/worker/handler/WorkerInitRequestHandler.java b/src/main/java/com/microsoft/azure/functions/worker/handler/WorkerInitRequestHandler.java index dff96f51..c37ac763 100644 --- a/src/main/java/com/microsoft/azure/functions/worker/handler/WorkerInitRequestHandler.java +++ b/src/main/java/com/microsoft/azure/functions/worker/handler/WorkerInitRequestHandler.java @@ -4,6 +4,8 @@ import com.microsoft.azure.functions.rpc.messages.*; import com.microsoft.azure.functions.worker.broker.JavaFunctionBroker; +import java.util.logging.Level; + public class WorkerInitRequestHandler extends MessageHandler { public WorkerInitRequestHandler(JavaFunctionBroker broker) { super(StreamingMessage::getWorkerInitRequest, @@ -15,6 +17,7 @@ public WorkerInitRequestHandler(JavaFunctionBroker broker) { @Override String execute(WorkerInitRequest request, WorkerInitResponse.Builder response) { + WorkerLogManager.getSystemLogger().log(Level.INFO, "WorkerInitRequest received by the Java worker"); broker.setWorkerDirectory(request.getWorkerDirectory()); response.setWorkerVersion(Application.version()); response.putCapabilities("TypedDataCollection", "TypedDataCollection");