Description
The timer used to periodically flush logs for DiagnosticEvents
is currently initialized as soon as the singleton Repository is created, regardless of whether any events are ever written.
With the change in Service Provider implementation in the OOP host, this behavior changed: singletons are now initialized eagerly at startup by JobHostScopedServiceProviderFactory
As a result, the Repository singleton—and its flush timer—are both created immediately when the child container is created, whether or not the Repository is ever actually resolved in the DiagnosticEventLogger
. This means the timer is running even if no events are ever written
Expected behavior
The timer should only be initialized the first time an event is actually written, rather than eagerly on startup. This would avoid unnecessary background timers in instances that never write any diagnostic event.