-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Agents stops sending logs after restarting the Azure functions #3173
Comments
the workaround now is to disable the agent explicitly using the config |
It seems the bug is coming from the warmup of the worker, the worker is using the FunctionEnvironmentReloadRequestHandler at warmup wish is Instrumented by the agent to configure the client once, but at this point I think the customer env variables are not set still so the agent is not configured properly at this point. but after the agent receives the correct ReloadRequest with the customer's configuration, it would not reconfigure because it was already configured at warmup. |
@ibrahim-abdellaoui what app service plan you notice this bug in? |
@shreyas-gopalakrishna Azure functions Consumption, OS windows. It will be better if I create a new function for tests that I can provide you |
Hi @ibrahim-abdellaoui , I have a few questions regards to this issue.
This seems incorrect to me as for the Consumption plan it should have Once you stop and start the function the JVM arguments you saw were
this is actually correct and expected. With So I think the issue is not why the logs are missing after stopping/starting the function app, instead, it's why the agent is enabled at the first deployment. Also, I am curious how were you able to check the JVM arguments. I don't think we expose this info anywhere to customers. Thanks. |
I tried deploy a consumption app, I cannot reproduce the issue. From our internal logs I see the correct profile AppInsightsPlaceholder is chosen, which maps to the correct JVM arguments with |
Hello @kaibocai, I had some time to test again and here are my findings:
private String getJVMArgs() {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = runtimeMxBean.getInputArguments();
return String.join(",", arguments);
}
@FunctionName("HttpExample")
public HttpResponseMessage run(
@HttpTrigger(
name = "req",
methods = {HttpMethod.GET, HttpMethod.POST},
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> request,
final ExecutionContext context) {
var telemetryClient = new TelemetryClient();
telemetryClient.trackTrace("log from ai sdk");
context.getLogger().info("log from default logger");
return request.createResponseBuilder(HttpStatus.OK)
.body(getJVMArgs())
.build();
} Also, I didn't specify
both logs appear in AI, the one logged via classic sdk has the
It seems now the worker starting using the warmup |
same test but now with 12:30 Added
the log from the classic sdk shows up in AI, and has the expected 12:31 restart the function
It seems after a config change or a deployment the function is not warmed up, the warmup only happens on restart or when the function goes in idle |
There are two agents I think we need to be clear about. @ibrahim-abdellaoui , I tried to reproduce the issue, with your code, I cannot reproduce the issue, everytime I deploy I am seeing The first deployment I only see Restart the app and still get the same JVM arguments Once I enable the java agent using This works as expected. Also I am using Maven plugin to deploy the app. I doubt there is a difference between using Maven and azure cli, since the backend API is the same, but if you get a chance can you try out using Maven plugin to deploy an Windows consumption app and test all this out? The command is really simple. Thanks. |
@kaibocai you are able to produce the bug in your tests and on your second run we see that the instance was run without warmup the missing To summarize all this, the bug is that when the instance used was warmed up (we know that because the env variable I also think deploying via maven will be the same but I will test it tomorrow for double checking. |
This is not a bug, it's a feature requires you to enable through appsetting |
but the classic sdk v2.x should work even without the agent attached, and that is the workaround that we are using now, forcing the agent not to be attached via the setting
|
to reproduce it set the |
Checkout the code here Line 84 in fc9b26c
The agent is not initialized if @trask should be able to confirm and help with
|
still this doesn't explain why in this test the logs are missing, I have the |
I think this is the source of the bug, hope this helps |
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
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:
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 enabledAPPLICATIONINSIGHTS_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:
The text was updated successfully, but these errors were encountered: