fix: add timeout to AppInsights flush to prevent blocking process exit#1532
Open
fix: add timeout to AppInsights flush to prevent blocking process exit#1532
Conversation
06c551d to
c9c13ad
Compare
Run flush in a daemon thread with a 5s timeout so AppInsights telemetry never blocks process exit when the Azure endpoint is unreachable (e.g. Automation Suite / CI environments with restricted egress). Previously the synchronous flush blocked indefinitely on URLError retries, keeping the process alive and leaving eval runs stuck in "Running" state.
c9c13ad to
604cd34
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
flush()now runs in adaemon=Truethread with a 5s timeoutuipathversion to2.10.40Problem
In Automation Suite environments, coded agent eval runs were getting stuck in Running state forever. The root cause:
AppInsightsEventClient.flush()is called (viafinallyblock oratexithandler)dc.applicationinsights.azure.comurlopen()times out →_DiagnosticSenderre-queues the items →SynchronousQueue.flush()retries in a loopAlpha works fine because it has outbound internet access and the flush completes in <1s.
Fix
Using
daemon=Trueensures the thread is abandoned on process exit even ifjoin()somehow doesn't return in time.Test plan
8 passed)