@@ -65,10 +65,13 @@ static class MetricsFlag {
6565 private static final AtomicReference <@ Nullable MetricsFlag > INSTANCE = new AtomicReference <>();
6666 final boolean counterDisabled ;
6767 final boolean stringSetDisabled ;
68+ final boolean boundedTrieDisabled ;
6869
69- private MetricsFlag (boolean counterDisabled , boolean stringSetDisabled ) {
70+ private MetricsFlag (
71+ boolean counterDisabled , boolean stringSetDisabled , boolean boundedTrieDisabled ) {
7072 this .counterDisabled = counterDisabled ;
7173 this .stringSetDisabled = stringSetDisabled ;
74+ this .boundedTrieDisabled = boundedTrieDisabled ;
7275 }
7376
7477 static boolean counterDisabled () {
@@ -80,6 +83,11 @@ static boolean stringSetDisabled() {
8083 MetricsFlag flag = INSTANCE .get ();
8184 return flag != null && flag .stringSetDisabled ;
8285 }
86+
87+ static boolean boundedTrieDisabled () {
88+ MetricsFlag flag = INSTANCE .get ();
89+ return flag != null && flag .boundedTrieDisabled ;
90+ }
8391 }
8492
8593 /**
@@ -101,7 +109,13 @@ public static void setDefaultPipelineOptions(PipelineOptions options) {
101109 if (stringSetDisabled ) {
102110 LOG .info ("StringSet metrics are disabled" );
103111 }
104- MetricsFlag .INSTANCE .compareAndSet (null , new MetricsFlag (counterDisabled , stringSetDisabled ));
112+ boolean boundedTrieDisabled =
113+ ExperimentalOptions .hasExperiment (exp , "disableBoundedTrieMetrics" );
114+ if (boundedTrieDisabled ) {
115+ LOG .info ("BoundedTrie metrics are disabled" );
116+ }
117+ MetricsFlag .INSTANCE .compareAndSet (
118+ null , new MetricsFlag (counterDisabled , stringSetDisabled , boundedTrieDisabled ));
105119 }
106120 }
107121
@@ -287,6 +301,9 @@ public MetricName getName() {
287301
288302 @ Override
289303 public void add (Iterable <String > values ) {
304+ if (MetricsFlag .boundedTrieDisabled ()) {
305+ return ;
306+ }
290307 MetricsContainer container = MetricsEnvironment .getCurrentContainer ();
291308 if (container != null ) {
292309 container .getBoundedTrie (name ).add (values );
0 commit comments