Skip to content

Native Chaos Engineering (Fault & Latency Injection)#52

Merged
cinar merged 2 commits intomainfrom
feat/issue-43
Apr 3, 2026
Merged

Native Chaos Engineering (Fault & Latency Injection)#52
cinar merged 2 commits intomainfrom
feat/issue-43

Conversation

@cinar
Copy link
Copy Markdown
Owner

@cinar cinar commented Apr 3, 2026

Overview

Implemented built-in middleware to safely inject synthetic failures and latency into the execution pipeline, enabling continuous verification of resilience policies (Retry, Bulkhead, Circuit Breaker) in staging or production.

Implementation Details

  • Chaos Package: New chaos package providing a thread-safe Injector that rolling for latency and error injection using math/rand/v2.
  • Policy Integration: Injected as the innermost middleware in both standard and hedged execution paths to simulate real action failures.
  • Context Awareness: Full support for context.Context cancellation during latency injection.
  • Zero Dependencies: Implementation uses only the Go standard library.
  • Adaptive Resilience: Seamlessly integrates with existing retry and circuit breaker policies.

Verification

  • Unit Tests: 100% coverage in chaos package.
  • Integration Tests: Added comprehensive tests in resile package to verify fault/latency injection and its interaction with other policies.
  • Overall Coverage: Increased resile package coverage to 93.1%.
  • Example: Added examples/chaos/main.go demonstrating usage.
  • Documentation: New technical article docs/articles/chaos-engineering.md and updated README.md.

Fixes #43

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.86%. Comparing base (350e07c) to head (f88ecec).

Files with missing lines Patch % Lines
chaos/injector.go 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   83.47%   91.86%   +8.39%     
==========================================
  Files          12       13       +1     
  Lines         853      897      +44     
==========================================
+ Hits          712      824     +112     
+ Misses        114       45      -69     
- Partials       27       28       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cinar cinar merged commit 55c53ad into main Apr 3, 2026
4 checks passed
@cinar cinar deleted the feat/issue-43 branch April 3, 2026 05:16
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.

Feature: Native Chaos Engineering (Fault & Latency Injection)

2 participants