Back to all reviewers

Judicious configuration management

grafana/grafana
Based on 4 comments
Go

Carefully manage configuration options, including feature flags, to balance flexibility with maintainability: 1. **Use feature flags strategically:**

Configurations Go

Reviewer Prompt

Carefully manage configuration options, including feature flags, to balance flexibility with maintainability:

  1. Use feature flags strategically:
    • Put new features behind feature flags for gradual rollout
    • Once fully deployed, remove the flag and make the feature standard
    • Avoid feature flags when default behavior naturally preserves backward compatibility
// Good: Feature flag for gradual rollout
if featuremgmt.AnyEnabled(&featuremgmt.FeatureManager{}, featuremgmt.FlagNewFeature) {
    providers = []app.Provider{playlistAppProvider, shortURLAppProvider}
} else {
    providers = []app.Provider{playlistAppProvider}
}

// Better when possible: Backward compatible default behavior
options := getCookieOptions()
if featuremgmt.AnyEnabled(&featuremgmt.FeatureManager{}, featuremgmt.FlagPanelExporterCookieDomain) {
    // Only modify behavior when flag is enabled
} else {
    options.Domain = "" // Maintains previous behavior
}
  1. Limit configuration points:
    • Start with fewer configuration options and add more only when needed
    • Remember that once a configuration option is exposed, removing it may break user workflows
    • Consider using appropriate metadata for feature flags (like HideFromDocs: true for internal features)
  2. Reuse existing configuration parsers rather than creating new ones to ensure consistent behavior across the application.
4
Comments Analyzed
Go
Primary Language
Configurations
Category

Source Discussions