Azure/azure-sdk-for-python

[azure-monitor-opentelemetry] how to force_flush() from a logger instance

copdips opened this issue · 2 comments

  • Package Name: azure-monitor-opentelemetry
  • Package Version: 1.4.1
  • Operating System: ubuntu 20.04
  • Python Version: 3.12

Describe the bug

With package azure-monitor-opentelemetry, I run configure_azure_monitor(logger_name=my_logger_name) to configure the logger.
Then I can get a logger instance from logging.getLogger(my_logger_name) that can send logs to Azure Application Insights.

For some use cases, I need to flush the logs instead of waiting for the auto flush interval. I find there's logger_provider.force_flush() method, but I need to access the logger_provider instance in advance. I'm wondering how to get this provider in my application.
From the logger instance, I can not find the related logger provider instance.

PS: maybe similar request for trace and metric.

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzmonActionG @azmonALERTS @AzMonEssential @AzmonLogA @dadunl @sameergMS.

Hi @copdips - Thanks for opening an issue! We'll take a look asap!