Skip to content

Commit ed127ef

Browse files
committed
update logic for setting capabilities
1 parent 5e098d5 commit ed127ef

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/com/microsoft/azure/functions/worker/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ private Constants(){}
1515
public final static String JAVA_LIBRARY_DIRECTORY = "/annotationLib";
1616
public final static String JAVA_LIBRARY_ARTIFACT_ID = "azure-functions-java-library";
1717
public final static String HAS_IMPLICIT_OUTPUT_QUALIFIED_NAME = "com.microsoft.azure.functions.annotation.HasImplicitOutput";
18+
public static final String JAVA_ENABLE_OPENTELEMETRY = "JAVA_ENABLE_OPENTELEMETRY";
19+
public static final String JAVA_APPLICATIONINSIGHTS_ENABLE_TELEMETRY = "JAVA_APPLICATIONINSIGHTS_ENABLE_TELEMETRY";
1820
}

src/main/java/com/microsoft/azure/functions/worker/handler/WorkerInitRequestHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.microsoft.azure.functions.worker.handler;
22

3-
import com.microsoft.azure.functions.internal.spi.middleware.Middleware;
43
import com.microsoft.azure.functions.worker.*;
54
import com.microsoft.azure.functions.rpc.messages.*;
65
import com.microsoft.azure.functions.worker.broker.JavaFunctionBroker;
76

87
import java.util.logging.Level;
98

9+
import static com.microsoft.azure.functions.worker.Constants.JAVA_APPLICATIONINSIGHTS_ENABLE_TELEMETRY;
10+
import static com.microsoft.azure.functions.worker.Constants.JAVA_ENABLE_OPENTELEMETRY;
11+
1012
public class WorkerInitRequestHandler extends MessageHandler<WorkerInitRequest, WorkerInitResponse.Builder> {
1113
public WorkerInitRequestHandler(JavaFunctionBroker broker) {
1214
super(StreamingMessage::getWorkerInitRequest,
@@ -28,7 +30,8 @@ String execute(WorkerInitRequest request, WorkerInitResponse.Builder response) {
2830
response.putCapabilities("HandlesWorkerTerminateMessage", "HandlesWorkerTerminateMessage");
2931
response.putCapabilities("HandlesWorkerWarmupMessage", "HandlesWorkerWarmupMessage");
3032

31-
if (Boolean.parseBoolean(System.getenv("JAVA_ENABLE_OPENTELEMETRY"))) {
33+
if (Boolean.parseBoolean(System.getenv(JAVA_ENABLE_OPENTELEMETRY)) ||
34+
Boolean.parseBoolean(System.getenv(JAVA_APPLICATIONINSIGHTS_ENABLE_TELEMETRY))) {
3235
response.putCapabilities("WorkerOpenTelemetryEnabled", "true");
3336
response.putCapabilities("WorkerApplicationInsightsLoggingEnabled", "true");
3437
}

0 commit comments

Comments
 (0)