Skip to content

Commit

Permalink
Fix azure functions consumption initialization (#3244)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Aug 23, 2023
1 parent 5517341 commit 965405b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ private DiagnosticsHelper() {}
}

public static void initRpIntegration(Path agentPath) {
if (!Strings.isNullOrEmpty(System.getenv("WEBSITE_SITE_NAME"))) {
// important to check FUNCTIONS_WORKER_RUNTIME before WEBSITE_SITE_NAME
// TODO (heya) how should we report functions windows users who are using app services
// windows attach by manually setting the env vars (which was the old documented way)
if ("java".equals(System.getenv("FUNCTIONS_WORKER_RUNTIME"))) {
rpIntegrationChar = 'f';
functionsRpIntegration = true;
setRpAttachType(agentPath, "functions.codeless");
} else if (!Strings.isNullOrEmpty(System.getenv("WEBSITE_SITE_NAME"))) {
rpIntegrationChar = 'a';
appSvcRpIntegration = true;
setRpAttachType(agentPath, "appsvc.codeless");
} else if (!Strings.isNullOrEmpty(System.getenv("KUBERNETES_SERVICE_HOST"))) {
rpIntegrationChar = 'k';
setRpAttachType(agentPath, "aks.codeless");
} else if ("java".equals(System.getenv("FUNCTIONS_WORKER_RUNTIME"))) {
rpIntegrationChar = 'f';
functionsRpIntegration = true;
setRpAttachType(agentPath, "functions.codeless");
} else if (!Strings.isNullOrEmpty(
System.getenv("APPLICATIONINSIGHTS_SPRINGCLOUD_SERVICE_ID"))) {
rpIntegrationChar = 's';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public void transform(TypeTransformer transformer) {
public static class ExecuteAdvice {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void methodExit() {

if (System.getenv("AzureWebJobsStorage") == null) {
// specialization hasn't occurred yet, and this is just a fake warmup request
return;
}

AzureFunctions.configureOnce();
}
}
Expand Down

0 comments on commit 965405b

Please sign in to comment.