Feature Flags Implementation
How to add a new feature flag
- Draft the flag in the service’s IaC — name, default, targeting rules, owner, target removal date.
- Wrap the new code path in a flag check at the outermost decision point.
- Add tests for both on and off paths.
- PR-review; merge → Runway deploys the flag definition to App Configuration.
- Confirm the SDK sees the flag with the default value.
How to roll out a flag safely
- Start with Alpha at 100 %; verify metrics + logs.
- Move to Beta at 100 %; monitor for a full business day.
- Enable on Prod at 5 – 10 % via percentage targeting.
- Ramp to 25 %, then 50 %, then 100 % with a monitoring window at each step.
- Once at 100 % for the observation window, plan flag retirement.
How to target a specific tenant / customer
- Add a targeting rule in IaC —
IncludedGroups: ["tenant-<id>"]or by custom attribute. - Confirm the SDK evaluation context passes the tenant ID.
- Deploy the rule via Runway.
- Verify with a synthetic request in that tenant’s scope.
How to use a flag as a kill switch
- Wrap the risky code path at the entry point (BFF handler, workflow trigger).
- Default the flag on in normal operation.
- During incident: platform on-call flips the flag off via the approved automation — audit event is emitted automatically.
- Sheddable behaviour engages within the SDK cache window (typically < 60 s).
- Post-incident: restore the flag; capture the incident in the DR runbook history.
How to activate degraded mode
See DR implementation — activate degraded service mode. Summary:
- Confirm the trigger with platform on-call.
- Toggle
degraded-modevia the emergency-toggle path. - Verify sheddable surfaces are shedding cleanly.
- Publish a status update.
- Restore the flag when the incident is resolved.
How to retire a flag
- Confirm the flag has been at 100 % for the observation window.
- Ship a PR removing the flag check and the alternate code branch.
- Once the PR is deployed everywhere, remove the flag definition from IaC.
- Deploy through Runway; App Config removes the flag.
- Confirm no remaining references in code, dashboards, or alerts.
How to review stale flags
- Query App Config evaluation metrics for flags with no evaluations in 30 days.
- Cross-check each with the code — is it still referenced?
- If unused: remove per the retirement recipe.
- If used but low-traffic: verify the targeting is still valid.
- Track outcomes in the platform’s flag inventory.
How to add an emergency-toggle audit trail entry
- Automatic — the platform audit pipeline emits an audit event on any flag value change.
- Post-hoc review: the next business day, security / platform on-call reviews all emergency toggles for justification.
- Missing justifications require a written follow-up.
How to test a flag before Prod
- Enable in Alpha at 100 % — verify feature works end-to-end.
- Enable for a synthetic tenant in Beta — verify targeting logic works.
- Run the standard integration tests in Beta with the flag on.
- Run production shadow traffic through the on / off paths where feasible.
How to handle an SDK cache staleness incident
- Confirm the flag change was published to App Config.
- Wait for the SDK refresh window (typically 30–60 s).
- If push-refresh is configured (Event Grid), verify the event fired.
- If staleness persists beyond an acceptable window, restart affected pods / instances as a last resort.
- Post-incident: verify cache configuration and push-refresh wiring.
How to query flag state across services
- Use the platform flag inventory dashboard (Grafana).
- Filter by owner, service, or state.
- For per-tenant evaluation, use the App Config query API with the tenant context.
Related
- Architecture, Guidelines
- Capabilities: DR, Audit Logs, Observability, CI/CD Runway
- ADRs: 0012, 0024