@@ -113,10 +113,12 @@ public void onResponse(
113113 new TreeMap <>(String ::compareToIgnoreCase );
114114
115115 RateSampler fallbackSampler = RateSamplersByEnvAndService .DEFAULT_SAMPLER ;
116+ boolean hasAgentRates = false ;
116117 for (final Map .Entry <String , Number > entry : newServiceRates .entrySet ()) {
117118 if (entry .getValue () == null ) {
118119 continue ;
119120 }
121+ hasAgentRates = true ;
120122 double rate = entry .getValue ().doubleValue ();
121123
122124 EnvAndService envAndService = EnvAndService .fromString (entry .getKey ());
@@ -157,7 +159,9 @@ public void onResponse(
157159 if (canIncrease && anyCapped ) {
158160 lastCappedNanos = now ;
159161 }
160- serviceRates = new RateSamplersByEnvAndService (updatedEnvServiceRates , fallbackSampler , true );
162+ serviceRates =
163+ new RateSamplersByEnvAndService (
164+ updatedEnvServiceRates , fallbackSampler , hasAgentRates );
161165 }
162166
163167 private static RateSampler createRateSampler (final double sampleRate ) {
@@ -179,6 +183,7 @@ private static final class RateSamplersByEnvAndService {
179183
180184 private final Map <String , TreeMap <String , RateSampler >> envServiceRates ;
181185 private final RateSampler fallbackSampler ;
186+ // Whether this snapshot contains at least one non-null Agent-provided rate.
182187 private final boolean hasAgentRates ;
183188
184189 RateSamplersByEnvAndService () {
0 commit comments