Description
Expected behavior
Describe what you expected to happen.
The agent keeps sending logs to AI after the function is restarted (manually or by the functions runtime)
Actual behavior
Describe what actually happened that was unexpected.
When the function is first deployed the agent seems to work properly also the VM options are set as
JVM arguments:-XX:+TieredCompilation
-XX:TieredStopAtLevel=1
-Xverify:none
-Djava.net.preferIPv4Stack=true
***** -javaagent:C:\Program Files (x86)\SiteExtensions\Functions\4.22.0\workers\java/agent/applicationinsights-agent.jar *****
but after restarting the Azure function, or waiting (around 20min idl) for the runtime to stop the function and then invoking it the logs are missing. also the VM options have changed to:
JVM arguments:-XX:+TieredCompilation
-XX:TieredStopAtLevel=1
-Xverify:none
-Djava.net.preferIPv4Stack=true
***** -javaagent:C:\Program Files (x86)\SiteExtensions\Functions\4.22.0\workers\java/agent/applicationinsights-agent.jar -DLazySetOptIn=false *****
there is a new -DLazySetOptIn that is set now, reading the azure java worker config it seems this comes from the env variable INITIALIZED_FROM_PLACEHOLDER: True
.
This also impacts using the old AI classic SDK (2.x), for the first run everything works fin and it is logged by the classic sdk, but after the restart, the logs are missing even tho the agent is not explicitly enabled.
I noticed also that after the restart there are no new entries in the applicationinsights.log
file (I have enabled APPLICATIONINSIGHTS_SELF_DIAGNOSTICS_LEVEL: debug
I don't know for sure if this is related to the Agent or the java worker, please let me know if I should create the issue in the Java worker repo instead.
To Reproduce
restarting the Azure function manually triggers this bug. and having APPLICATIONINSIGHTS_ENABLE_AGENT: True
System information
Please provide the following information:
- SDK Version: Azure functions 4.x, Agent 3.4.11
- OS type and version: Windows
- Application Server type and version (if applicable):
- Using spring-boot? No
- Additional relevant libraries (with version, if applicable):