Skip to content
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

AI logs are not flushed when process exits #2379

Open
dmytro-gokun opened this issue Apr 4, 2024 · 2 comments
Open

AI logs are not flushed when process exits #2379

dmytro-gokun opened this issue Apr 4, 2024 · 2 comments

Comments

@dmytro-gokun
Copy link

Description

We have a .NET 8 function app (isolated). When the app starts we register this lifetime callbacks:

    public static IHost InitializeLogging(this IHost @this)
    {
        var logger = @this.Services.GetRequiredService<ILogger<ApplicationLog>>();
        var lifetime = @this.Services.GetRequiredService<IHostApplicationLifetime>();
        lifetime.ApplicationStarted.Register(() => logger.LogInformation("Application started"));
        lifetime.ApplicationStopping.Register(() => logger.LogInformation("Application stopping"));
        lifetime.ApplicationStopped.Register(() => logger.LogInformation("Application stopped"));
        return @this;
    }

In this application we also have configured Application Insights logging using services.AddApplicationInsightsTelemetryWorkerService()/services.ConfigureFunctionsApplicationInsights().

All in all, logging works just fine and we get all our log in AI. "Application started" is getting to AI as well. But we never get "Application stopping"/"Application stopped" in AI. My assumption is that the function app exits before those message are actually transmitted to AI server. Is this correct? Is there any way to fix this behavior?

Steps to reproduce

  1. Create an Azure Function app.
  2. Add Application insights logging.
  3. Log lifetime events
  4. Deploy Function app to Azure and run it.
  5. Make sure its stopped.
  6. Examine AI logs.
@dmytro-gokun
Copy link
Author

@liliankasem I've done some additional testing and i can confirm that ApplicationStopping & ApplicationStopped events are fired indeed. So the problem (most likely) is in some events not reaching AI indeed. I think, we need some fix for this

@dmytro-gokun
Copy link
Author

Is there any chance this gets worked on any time soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants