One of the most powerful aspects of Simmy is that every option accepting a delegate receives a PollyDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Polly-Contrib/Simmy/llms.txt
Use this file to discover all available pages before exploring further.
Context object and a CancellationToken. This means chaos behaviour — whether it fires at all, how often, what fault to throw, how long to delay — can be computed at the moment of each individual call rather than fixed at application startup. By combining Context with an external configuration source such as an app-settings file, Azure App Configuration, or a feature-flag service, you can turn chaos on and off, adjust injection rates, and target individual operations without touching code or redeploying.
What is Polly Context?
A PollyContext is a dictionary-like object that travels with every policy execution. It can carry arbitrary key/value data, but its most important built-in property for targeting purposes is OperationKey — a free-text string you set at call time that identifies the logical operation being performed.
EnabledWhen, InjectionRate, Fault, Latency, Behaviour) receives this context as its first argument. Reading ctx.OperationKey lets a single shared chaos policy make different decisions for different callers.
Targeting Specific Operations
Rather than creating one policy per operation, build one policy that readsctx.OperationKey inside its delegates and applies different behaviour based on which operation is executing.
Driving Chaos from External Configuration
Hard-coding injection rates and enabled flags makes chaos policies rigid. The delegate overloads let you call out to a configuration service on every execution, so the chaos settings can change at runtime.Create a configuration service
Define a service that reads the current chaos settings. This might wrap Azure App Configuration, a database table, or a simple in-memory store toggled by an admin endpoint.
Build the policy with delegate overloads
Wire the policy so that each execution reads live configuration.
Tag executions with OperationKey
At each call site, attach a context that identifies the logical operation.
The EnabledWhen + InjectionRate Pattern
This is the full production pattern combining environment checks, per-operation targeting, and dynamic rates:EnabledWhen delegate acts as a master gate. When it returns false the policy is entirely dormant — InjectionRate is not even evaluated — so there is zero cost to leaving chaos policies registered in production builds so long as IsChaosEnabled returns false.
Passing Custom Data via Context
BeyondOperationKey, Context can hold arbitrary entries via its dictionary interface. This lets callers pass extra information to chaos delegates.
Reference: The Simmy Sample App
The Simmy Demo WebAPI sample provides a complete, runnable illustration of these patterns, demonstrating:- Startup-only injection: chaos policies are registered only when the hosting environment is
DevelopmentorStaging, ensuring they never execute in production builds. - Runtime configuration: chaos settings (enabled flag, injection rate, fault type) are stored in an external configuration store and read at execution time through delegate overloads, so a developer can turn chaos on and off by updating configuration without touching code.
- Per-operation targeting: each outbound HTTP call is tagged with an
OperationKeymatching the downstream service name, and the configuration store holds per-operation settings.
The patterns shown in the sample app are starting points, not requirements. Simmy is intentionally flexible — the delegate-based API places no constraints on where or how you read your chaos configuration.
Benefits Summary
| Capability | How Simmy enables it |
|---|---|
| Enable / disable chaos without redeploying | EnabledWhen reads live flag from config service |
| Adjust injection rate at runtime | InjectionRate delegate reads live value from config service |
| Target one operation, not all | Read ctx.OperationKey inside any delegate |
| Different faults per operation | Fault delegate switches on ctx.OperationKey |
| Pass extra call-site data to delegates | Store in Context dictionary, read in delegate |