Skip to content

fix: remove Thread.sleep chaos injection from CreditCardService; add latency gate and regression test#74

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-thread-sleep-chaos-injection
Draft

fix: remove Thread.sleep chaos injection from CreditCardService; add latency gate and regression test#74
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-thread-sleep-chaos-injection

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

Random 0–9s Thread.sleep on every GET /api/cards request caused avg response times of 1–7.6s (SLA: <200ms), triggering Azure Monitor alert alert-latency-sre-three-rivers.

Changes

  • CreditCardService.java — Remove chaos injection:

    - try { Thread.sleep((long)(Math.random() * 9000)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); }
  • ci.yml — Fail CI if Thread.sleep appears in backend/src/main/, preventing recurrence:

    - name: Check for Thread.sleep in production code
      run: |
        if grep -rn "Thread\.sleep" backend/src/main/; then
          echo "ERROR: Thread.sleep found in production source code. Remove it before merging."
          exit 1
        fi
  • CreditCardServiceTest.java — Latency regression test asserting getAllCreditCards() completes in <500ms using System.nanoTime().


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

…latency test and CI gate

Co-authored-by: yortch <4576246+yortch@users.noreply.github.com>
Agent-Logs-Url: https://github.com/yortch/agentic-devops-demo/sessions/c3ecea25-6e69-4153-a093-2e6128ce6e7e
Copilot AI changed the title [WIP] Fix elevated backend latency in CreditCardService fix: remove Thread.sleep chaos injection from CreditCardService; add latency gate and regression test Mar 25, 2026
Copilot AI requested a review from yortch March 25, 2026 16:46
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.

🔴 Elevated Backend Latency — Thread.sleep Chaos Injection in CreditCardService (Sev3)

2 participants