Repository: istio/istio
Pull request #56252: remove deferred stats creation flag
Author: login: ramaraochavali
Labels: name: size/M
description: Denotes a PR that changes 30-99 lines, ignoring generated files.
name: release-notes-none
description: Indicates a PR that does not require release notes.
Created: 2025-05-10T09:39:38Z | Merged: 2025-05-16T18:33:09Z

**Please provide a description of this PR:**


Diff:
diff --git a/pilot/pkg/features/experimental.go b/pilot/pkg/features/experimental.go
index 9549f8f1cd7..c96d415048f 100644
--- a/pilot/pkg/features/experimental.go
+++ b/pilot/pkg/features/experimental.go
@@ -182,9 +182,6 @@ var (
 	Enable100ContinueHeaders = env.Register("ENABLE_100_CONTINUE_HEADERS", true,
 		"If enabled, istiod will proxy 100-continue headers as is").Get()
 
-	EnableDeferredStatsCreation = env.Register("ENABLE_DEFERRED_STATS_CREATION", true,
-		"If enabled, Istio will lazily initialize a subset of the stats").Get()
-
 	EnableLocalityWeightedLbConfig = env.Register("ENABLE_LOCALITY_WEIGHTED_LB_CONFIG", false,
 		"If enabled, always set LocalityWeightedLbConfig for a cluster, "+
 			" otherwise only apply it when locality lb is specified by DestinationRule for a service").Get()
diff --git a/pkg/bootstrap/config.go b/pkg/bootstrap/config.go
index b3b2fd02210..fcf4722b69c 100644
--- a/pkg/bootstrap/config.go
+++ b/pkg/bootstrap/config.go
@@ -128,7 +128,6 @@ func (cfg Config) toTemplateParams() (map[string]any, error) {
 		option.XdsType(xdsType),
 		option.MetadataDiscovery(mDiscovery),
 		option.MetricsLocalhostAccessOnly(cfg.Metadata.ProxyConfig.ProxyMetadata),
-		option.DeferredStatsCreation(features.EnableDeferredStatsCreation),
 		option.BypassOverloadManagerForStaticListeners(features.BypassOverloadManagerForStaticListeners),
 	)
 
diff --git a/pkg/bootstrap/option/instances.go b/pkg/bootstrap/option/instances.go
index 1476883959e..332ce62b53c 100644
--- a/pkg/bootstrap/option/instances.go
+++ b/pkg/bootstrap/option/instances.go
@@ -271,10 +271,6 @@ func MetricsLocalhostAccessOnly(proxyMetadata map[string]string) Instance {
 	return newOption("metrics_localhost_access_only", false)
 }
 
-func DeferredStatsCreation(deferred bool) Instance {
-	return newOption("deferred_stats_creation", deferred)
-}
-
 func BypassOverloadManagerForStaticListeners(bypass bool) Instance {
 	return newOption("bypass_overload_manager", bypass)
 }
diff --git a/pkg/bootstrap/testdata/all_golden.json b/pkg/bootstrap/testdata/all_golden.json
index 4dac40c5900..b573908dfc5 100644
--- a/pkg/bootstrap/testdata/all_golden.json
+++ b/pkg/bootstrap/testdata/all_golden.json
@@ -576,10 +576,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/ambient_golden.json b/pkg/bootstrap/testdata/ambient_golden.json
index 63a96a58edc..94b1a4a6c52 100644
--- a/pkg/bootstrap/testdata/ambient_golden.json
+++ b/pkg/bootstrap/testdata/ambient_golden.json
@@ -456,10 +456,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/auth_golden.json b/pkg/bootstrap/testdata/auth_golden.json
index df7023ced56..19a2b351dac 100644
--- a/pkg/bootstrap/testdata/auth_golden.json
+++ b/pkg/bootstrap/testdata/auth_golden.json
@@ -443,10 +443,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/authsds_golden.json b/pkg/bootstrap/testdata/authsds_golden.json
index 58864bd3acc..0af776ca582 100644
--- a/pkg/bootstrap/testdata/authsds_golden.json
+++ b/pkg/bootstrap/testdata/authsds_golden.json
@@ -443,10 +443,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/default_golden.json b/pkg/bootstrap/testdata/default_golden.json
index e9f6caa80a9..f6970399169 100644
--- a/pkg/bootstrap/testdata/default_golden.json
+++ b/pkg/bootstrap/testdata/default_golden.json
@@ -443,10 +443,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/explicit_internal_address_golden.json b/pkg/bootstrap/testdata/explicit_internal_address_golden.json
index d799cc9718a..0896ce24088 100644
--- a/pkg/bootstrap/testdata/explicit_internal_address_golden.json
+++ b/pkg/bootstrap/testdata/explicit_internal_address_golden.json
@@ -443,10 +443,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/lrs_golden.json b/pkg/bootstrap/testdata/lrs_golden.json
index bc4e4c0354e..5c9d1abea47 100644
--- a/pkg/bootstrap/testdata/lrs_golden.json
+++ b/pkg/bootstrap/testdata/lrs_golden.json
@@ -445,10 +445,8 @@
     ,
     "load_stats_config":{"api_type": "GRPC", "transport_api_version": "V3"}
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/metrics_no_statsd_golden.json b/pkg/bootstrap/testdata/metrics_no_statsd_golden.json
index 98fd749f72d..792f909b6ca 100644
--- a/pkg/bootstrap/testdata/metrics_no_statsd_golden.json
+++ b/pkg/bootstrap/testdata/metrics_no_statsd_golden.json
@@ -495,10 +495,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/running_golden.json b/pkg/bootstrap/testdata/running_golden.json
index 08bf4309af2..f18232a5762 100644
--- a/pkg/bootstrap/testdata/running_golden.json
+++ b/pkg/bootstrap/testdata/running_golden.json
@@ -503,10 +503,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/runningsds_golden.json b/pkg/bootstrap/testdata/runningsds_golden.json
index 74fb8d1462a..70e099e07cc 100644
--- a/pkg/bootstrap/testdata/runningsds_golden.json
+++ b/pkg/bootstrap/testdata/runningsds_golden.json
@@ -503,10 +503,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/stats_compression_brotli_golden.json b/pkg/bootstrap/testdata/stats_compression_brotli_golden.json
index a5ee644b84a..95c31201100 100644
--- a/pkg/bootstrap/testdata/stats_compression_brotli_golden.json
+++ b/pkg/bootstrap/testdata/stats_compression_brotli_golden.json
@@ -588,10 +588,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/stats_compression_gzip_golden.json b/pkg/bootstrap/testdata/stats_compression_gzip_golden.json
index 4cbe6bde7d5..3863cbc39bc 100644
--- a/pkg/bootstrap/testdata/stats_compression_gzip_golden.json
+++ b/pkg/bootstrap/testdata/stats_compression_gzip_golden.json
@@ -588,10 +588,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/stats_compression_unknown_golden.json b/pkg/bootstrap/testdata/stats_compression_unknown_golden.json
index 482348c8b12..201bce0e363 100644
--- a/pkg/bootstrap/testdata/stats_compression_unknown_golden.json
+++ b/pkg/bootstrap/testdata/stats_compression_unknown_golden.json
@@ -576,10 +576,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/stats_compression_zstd_golden.json b/pkg/bootstrap/testdata/stats_compression_zstd_golden.json
index 7e38833eb96..705ea44a9fb 100644
--- a/pkg/bootstrap/testdata/stats_compression_zstd_golden.json
+++ b/pkg/bootstrap/testdata/stats_compression_zstd_golden.json
@@ -588,10 +588,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/stats_inclusion_golden.json b/pkg/bootstrap/testdata/stats_inclusion_golden.json
index 78b7d374fe4..deb5d131f25 100644
--- a/pkg/bootstrap/testdata/stats_inclusion_golden.json
+++ b/pkg/bootstrap/testdata/stats_inclusion_golden.json
@@ -537,10 +537,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/tracing_datadog_golden.json b/pkg/bootstrap/testdata/tracing_datadog_golden.json
index 1f56ef9fc52..55ccf513d68 100644
--- a/pkg/bootstrap/testdata/tracing_datadog_golden.json
+++ b/pkg/bootstrap/testdata/tracing_datadog_golden.json
@@ -478,10 +478,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/tracing_lightstep_golden.json b/pkg/bootstrap/testdata/tracing_lightstep_golden.json
index c5b5c672195..ea65385a9d4 100644
--- a/pkg/bootstrap/testdata/tracing_lightstep_golden.json
+++ b/pkg/bootstrap/testdata/tracing_lightstep_golden.json
@@ -485,10 +485,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/tracing_none_golden.json b/pkg/bootstrap/testdata/tracing_none_golden.json
index 9a33ed2b219..92e264c67f6 100644
--- a/pkg/bootstrap/testdata/tracing_none_golden.json
+++ b/pkg/bootstrap/testdata/tracing_none_golden.json
@@ -443,10 +443,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/tracing_tls_custom_sni_golden.json b/pkg/bootstrap/testdata/tracing_tls_custom_sni_golden.json
index 3e660b81b0e..afeac69f2f8 100644
--- a/pkg/bootstrap/testdata/tracing_tls_custom_sni_golden.json
+++ b/pkg/bootstrap/testdata/tracing_tls_custom_sni_golden.json
@@ -482,10 +482,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/tracing_tls_golden.json b/pkg/bootstrap/testdata/tracing_tls_golden.json
index ac5dfbd2248..952a7fee14c 100644
--- a/pkg/bootstrap/testdata/tracing_tls_golden.json
+++ b/pkg/bootstrap/testdata/tracing_tls_golden.json
@@ -482,10 +482,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/tracing_zipkin_golden.json b/pkg/bootstrap/testdata/tracing_zipkin_golden.json
index 62011c0b60b..138bbb72dcc 100644
--- a/pkg/bootstrap/testdata/tracing_zipkin_golden.json
+++ b/pkg/bootstrap/testdata/tracing_zipkin_golden.json
@@ -481,10 +481,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/pkg/bootstrap/testdata/xdsproxy_golden.json b/pkg/bootstrap/testdata/xdsproxy_golden.json
index 7deb6ed84fe..8e4ac81dc7c 100644
--- a/pkg/bootstrap/testdata/xdsproxy_golden.json
+++ b/pkg/bootstrap/testdata/xdsproxy_golden.json
@@ -443,10 +443,8 @@
       "event_log_path": "/dev/stdout"
     }
   }
-  
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  
 }
diff --git a/tools/packaging/common/envoy_bootstrap.json b/tools/packaging/common/envoy_bootstrap.json
index 8d5de3c9ce2..fd6bd027c17 100644
--- a/tools/packaging/common/envoy_bootstrap.json
+++ b/tools/packaging/common/envoy_bootstrap.json
@@ -822,10 +822,8 @@
     {{- end }}
   }
   {{- end }}
-  {{ if .deferred_stats_creation }}
   ,
   "deferred_stat_options": {
     "enable_deferred_creation_stats": true
   }
-  {{ end }}
 }


Reviews:
user: login: zirain
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-10T09:43:56Z
user: login: howardjohn
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-11T22:04:21Z
user: login: ramaraochavali
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-12T03:22:42Z
user: login: keithmattix
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-16T16:34:02Z

Review comments:
diff_hunk: @@ -446,9 +446,4 @@
     "load_stats_config":{"api_type": "GRPC", "transport_api_version": "V3"}
   }
   
-  ,
-  "deferred_stat_options": {
-    "enable_deferred_creation_stats": true
path: pkg/bootstrap/testdata/lrs_golden.json
user: login: howardjohn
body: isn't this switching it to false? shouldn't it be true? 
created_at: 2025-05-11T22:04:18Z
author_association: MEMBER
diff_hunk: @@ -446,9 +446,4 @@
     "load_stats_config":{"api_type": "GRPC", "transport_api_version": "V3"}
   }
   
-  ,
-  "deferred_stat_options": {
-    "enable_deferred_creation_stats": true
path: pkg/bootstrap/testdata/lrs_golden.json
user: login: ramaraochavali
body: Yes. One of Cursor failures to not able to detect template change. Fixed it :-)
created_at: 2025-05-12T03:22:42Z
author_association: CONTRIBUTOR

PR comments:
user: login: ramaraochavali
created_at: 2025-05-16T11:43:00Z
body: @keithmattix @hzxuzhonghu can you PTAL?
author_association: CONTRIBUTOR
user: login: keithmattix
created_at: 2025-05-16T18:05:10Z
body: /test integ-security-multicluster
author_association: CONTRIBUTOR
user: login: aa2811
created_at: 2025-09-05T12:12:44Z
body: Could I please ask why this was removed? 

We were using this flag in testing to make sure that all the stats we relied on from envoy were present, without having to e.g. simulate a bind error.

Also I would have expected to see something in the release notes about this removal, given it was announced in the original 1.24 release note [here](https://istio.io/latest/news/releases/1.24.x/announcing-1.24/change-notes/#traffic-management )
author_association: NONE
user: login: ramaraochavali
created_at: 2025-09-06T06:05:06Z
body: > Could I please ask why this was removed?

All the env vars introduced will have a short life time and especially meant for seam less upgrades. After couple of releases they will be removed to give chance for users to validate.

> Also I would have expected to see something in the release notes about this removal, given it was announced in the original 1.24 release note [here](https://istio.io/latest/news/releases/1.24.x/announcing-1.24/change-notes/#traffic-management)

Apologies for missing the release notes here.



author_association: CONTRIBUTOR