Skip to content

Replace hardcoded sleep with polling for CloudWatch Logs Insights queries#20

Merged
llama90 merged 4 commits intofeat/e2e-performance-trackingfrom
copilot/sub-pr-18
Jan 4, 2026
Merged

Replace hardcoded sleep with polling for CloudWatch Logs Insights queries#20
llama90 merged 4 commits intofeat/e2e-performance-trackingfrom
copilot/sub-pr-18

Conversation

Copy link
Contributor

Copilot AI commented Jan 3, 2026

The analyze-performance.sh script used hardcoded sleep values (5s, 8s) when waiting for CloudWatch Logs Insights queries, which are insufficient under high load or in high-latency regions.

Changes

  • Polling mechanism: Implemented wait_for_query_completion() that polls query status until completion, timeout, or failure

    • Handles all query states: Complete, Failed, Cancelled, Timeout, Running, Scheduled
    • Validates AWS CLI exit codes and JSON parsing separately for better error diagnostics
    • Logs unexpected status values for debugging
  • Configuration: Added environment variables for tuning

    • CLOUDWATCH_QUERY_MAX_WAIT (default: 60s) - maximum wait time
    • CLOUDWATCH_QUERY_POLL_INTERVAL (default: 2s) - polling interval
  • Replaced: All 7 hardcoded sleep calls with polling function

Example

# Adjust for high-latency regions or large log volumes
export CLOUDWATCH_QUERY_MAX_WAIT=120
export CLOUDWATCH_QUERY_POLL_INTERVAL=3

./analyze-performance.sh --from-test

The polling mechanism returns immediately on query completion rather than waiting fixed delays, making it more efficient for both fast and slow queries.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 3, 2026 19:12
…eries

Co-authored-by: llama90 <6668548+llama90@users.noreply.github.com>
Co-authored-by: llama90 <6668548+llama90@users.noreply.github.com>
Copilot AI changed the title [WIP] Update E2E performance tracking based on feedback Replace hardcoded sleep with polling for CloudWatch Logs Insights queries Jan 3, 2026
Copilot AI requested a review from llama90 January 3, 2026 19:16
- Fix .metrics.json being selected instead of test results
- Fix timestamp conversion from milliseconds to seconds for AWS CLI
- Add dynamic CloudWatch period calculation to avoid 1440 datapoint limit
- Fix AWS statistics parameter format (space-separated instead of comma)
- Add error handling for CloudWatch queries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@llama90 llama90 marked this pull request as ready for review January 4, 2026 03:40
@llama90 llama90 merged commit d000031 into feat/e2e-performance-tracking Jan 4, 2026
@llama90 llama90 deleted the copilot/sub-pr-18 branch January 4, 2026 03:41
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.

2 participants