So far, you’ve learned a variety of ways to apply chaos engineering to a selection of different systems. The languages, tools, and approaches varied, but they all had one thing in common: working with source code outside your control. If you’re in a role like SRE or platform engineer, that’s going to be your bread and butter. But sometimes you will have the luxury of applying chaos engineering to your own code.
This chapter focuses on baking chaos engineering options directly into your application for a quick, easy, and—dare I say it—fun way of increasing your confidence in the overall stability of the system as a whole. I’ll guide you through designing and running two experiments: one injecting latency into functions responsible for communicating with an external cache, and another injecting intermittent failure through the simple means of raising an exception. The example code is written in Python, but don’t worry if it’s not your forte; I promise to keep it basic.