Skip to content

Only start flush logs timer when there's an event to write #11100

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

Merged
merged 7 commits into from
Jun 6, 2025

Conversation

cjaliaga
Copy link
Member

@cjaliaga cjaliaga commented May 30, 2025

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.

var jobHostServices = _rootProvider.CreateChildContainer(_rootServices);

resolves #11098

Changes:

  • Transitions the _flushLogsTimer to a lazy initialization pattern, ensuring the timer is only started when there's an event to write.
  • Changed logging levels from Error to Warning to better reflect the severity of the issues.
  • Disabled the service when there's any failure (even if transient) as part of flush logs, purge events or execute batch.

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

@cjaliaga cjaliaga requested a review from a team as a code owner May 30, 2025 10:54
Copy link
Contributor

@jviau jviau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Changing the log level could be considered a breaking change (a very minor one at that). But I think the recent customer issues warrants the change.

@cjaliaga cjaliaga force-pushed the cjaliaga/diagnosticevents-timer-lazy-init branch from cf77389 to 5f800fd Compare June 4, 2025 14:18
@jviau jviau self-requested a review June 4, 2025 16:48
@cjaliaga cjaliaga requested a review from RohitRanjanMS June 6, 2025 11:16
@cjaliaga cjaliaga merged commit 265424c into dev Jun 6, 2025
9 checks passed
@cjaliaga cjaliaga deleted the cjaliaga/diagnosticevents-timer-lazy-init branch June 6, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timer for Diagnostic Events log flush is initialized on startup, even when no events are written
3 participants