Repository: envoyproxy/envoy
File: source/common/runtime/runtime_features.cc (C++)

Code before:

// TODO(grnmeira):
// Enables the new DNS implementation, a merged implementation of
// strict and logical DNS clusters. This new implementation will
// take over the split ones, and will be used as a base for the
// implementation of on-demand DNS.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_enable_new_dns_implementation);
// Force a local reply from upstream envoy for reverse connections.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_reverse_conn_force_local_reply);
// RELEASE_ASSERT when upstream stream detects UAF of downstream response decoder instance.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_abort_when_accessing_dead_decoder);
// TODO(pradeepcrao): Create a config option to enable this instead after
// testing.
FALSE_RUNTIME_GUARD(envoy_restart_features_use_cached_grpc_client_for_xds);
// Runtime guard to revert back to old non-RFC-compliant CONNECT behavior without Host header.
// TODO(vinaykul): Drop this false-runtime-guard when deemed safe with RFC 9110 compliant CONNECT.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_http_11_proxy_connect_legacy_format);
// TODO(tsaarni): Flip to true after prod testing or remove.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_fixed_heap_use_allocated);
// Flip back to true once performance aligns with nghttp2 and
// https://github.com/envoyproxy/envoy/issues/40070 is resolved.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_http2_use_oghttp2);
// When enabled, dynamic modules metrics will be registered as custom stat namespaces, causing
// the namespace prefix to be stripped from prometheus output and no envoy_ prefix added.
// This is the legacy behavior. When disabled which is the default, metrics appear with the
// standard envoy_ prefix followed by the namespace (e.g. envoy_myapp_requests_total).
FALSE_RUNTIME_GUARD(envoy_reloadable_features_dynamic_modules_strip_custom_stat_prefix);

// Block of non-boolean flags. Use of int flags is deprecated. Do not add more.
ABSL_FLAG(uint64_t, re2_max_program_size_error_level, 100, ""); // NOLINT
ABSL_FLAG(uint64_t, re2_max_program_size_warn_level,            // NOLINT
          std::numeric_limits<uint32_t>::max(), "");            // NOLINT

namespace Envoy {
namespace Runtime {
namespace {

std::string swapPrefix(std::string name) {
  return absl::StrReplaceAll(name, {{"envoy_", "envoy."}, {"features_", "features."}});
}

} // namespace

RuntimeFeatures::RuntimeFeatures() {
  absl::flat_hash_map<absl::string_view, absl::CommandLineFlag*> flags = absl::GetAllFlags();
  for (auto& it : flags) {
    absl::string_view name = it.second->Name();
    if ((!absl::StartsWith(name, "envoy_reloadable_features_") &&
         !absl::StartsWith(name, "envoy_restart_features_")) ||
        !it.second->TryGet<bool>().has_value()) {
      continue;

Review comment (suggestion):
```suggestion
// standard envoy_ prefix followed by the namespace.
```

Code after:

// TODO(grnmeira):
// Enables the new DNS implementation, a merged implementation of
// strict and logical DNS clusters. This new implementation will
// take over the split ones, and will be used as a base for the
// implementation of on-demand DNS.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_enable_new_dns_implementation);
// Force a local reply from upstream envoy for reverse connections.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_reverse_conn_force_local_reply);
// RELEASE_ASSERT when upstream stream detects UAF of downstream response decoder instance.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_abort_when_accessing_dead_decoder);
// TODO(pradeepcrao): Create a config option to enable this instead after
// testing.
FALSE_RUNTIME_GUARD(envoy_restart_features_use_cached_grpc_client_for_xds);
// Runtime guard to revert back to old non-RFC-compliant CONNECT behavior without Host header.
// TODO(vinaykul): Drop this false-runtime-guard when deemed safe with RFC 9110 compliant CONNECT.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_http_11_proxy_connect_legacy_format);
// TODO(tsaarni): Flip to true after prod testing or remove.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_fixed_heap_use_allocated);
// Flip back to true once performance aligns with nghttp2 and
// https://github.com/envoyproxy/envoy/issues/40070 is resolved.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_http2_use_oghttp2);
// When enabled, dynamic modules metrics will be registered as custom stat namespaces, causing
// the namespace prefix to be stripped from prometheus output and no envoy_ prefix added.
// This is the legacy behavior. When disabled which is the default, metrics appear with the
// standard envoy_ prefix followed by the namespace.
FALSE_RUNTIME_GUARD(envoy_reloadable_features_dynamic_modules_strip_custom_stat_prefix);

// Block of non-boolean flags. Use of int flags is deprecated. Do not add more.
ABSL_FLAG(uint64_t, re2_max_program_size_error_level, 100, ""); // NOLINT
ABSL_FLAG(uint64_t, re2_max_program_size_warn_level,            // NOLINT
          std::numeric_limits<uint32_t>::max(), "");            // NOLINT

namespace Envoy {
namespace Runtime {
namespace {

std::string swapPrefix(std::string name) {
  return absl::StrReplaceAll(name, {{"envoy_", "envoy."}, {"features_", "features."}});
}

} // namespace

RuntimeFeatures::RuntimeFeatures() {
  absl::flat_hash_map<absl::string_view, absl::CommandLineFlag*> flags = absl::GetAllFlags();
  for (auto& it : flags) {
    absl::string_view name = it.second->Name();
    if ((!absl::StartsWith(name, "envoy_reloadable_features_") &&
         !absl::StartsWith(name, "envoy_restart_features_")) ||
        !it.second->TryGet<bool>().has_value()) {
      continue;