Skip to content

fix: intermittent app insights event loss in serverless env#1371

Merged
cristian-groza merged 2 commits intomainfrom
fix/app-insights-telemetry
Feb 26, 2026
Merged

fix: intermittent app insights event loss in serverless env#1371
cristian-groza merged 2 commits intomainfrom
fix/app-insights-telemetry

Conversation

@cristian-groza
Copy link
Contributor

Summary

  • Register atexit flush handler on every track_event call (not just CLI), so buffered events are sent on graceful shutdown even if the caller never explicitly flushes
  • Parse and use IngestionEndpoint from the connection string instead of always hitting the global default endpoint
  • Replace SynchronousSender with _DiagnosticSender that logs HTTP 400 (silently discarded by SDK), network timeouts, and other failures at WARNING level
  • Log remaining queue size after flush to surface partial send failures

Context

AgentRun.Start custom events were intermittently missing from App Insights despite serverless logs confirming the SDK track_event call completed. Root causes:

  1. Events buffered but never flushed — the agent execution path didn't register an atexit handler (only CLI did), so if the process exited before the finally block, the in-memory queue was lost
  2. SDK silently discards HTTP 400SenderBase.send() swallows 400 responses without logging, making schema/ikey rejections invisible
  3. Wrong ingestion endpoint_parse_connection_string() only extracted InstrumentationKey, ignoring IngestionEndpoint, causing events to route to the global endpoint instead of the regional one

@github-actions github-actions bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository labels Feb 25, 2026
@cristian-groza cristian-groza force-pushed the fix/app-insights-telemetry branch from c16900b to 3045931 Compare February 26, 2026 08:58
@cristian-groza cristian-groza merged commit e7f925b into main Feb 26, 2026
65 of 66 checks passed
@cristian-groza cristian-groza deleted the fix/app-insights-telemetry branch February 26, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants