@Test public void create_forChildContext() { TraceOptionsFactory traceOptionsFactory = new RateLimitingTraceOptionsFactory(ratelimiter, true); TraceOptions traceOptions = new TraceOptions(); assertThat(traceOptionsFactory.create(traceOptions)).isEqualTo(traceOptions); }
@Override public TraceOptions create() { boolean traceEnabled = rateLimiter.tryAcquire(); return new TraceOptions() .overrideTraceEnabled(traceEnabled) .overrideStackTraceEnabled(stackTraceEnabled); }
RateLimitingTraceOptionsFactory implements TraceOptionsFactory { @Override public TraceOptions create() { boolean traceEnabled = rateLimiter.tryAcquire(); return new TraceOptions() .overrideTraceEnabled(traceEnabled) .overrideStackTraceEnabled(stackTraceEnabled); } }
RateLimitingTraceOptionsFactory implements TraceOptionsFactory { @Override public TraceOptions create() { boolean traceEnabled = rateLimiter.tryAcquire(); return new TraceOptions() .overrideTraceEnabled(traceEnabled) .overrideStackTraceEnabled(stackTraceEnabled); } RateLimitingTraceOptionsFactory(double samplingRate, boolean stackTraceEnabled); @VisibleForTesting  RateLimitingTraceOptionsFactory(RateLimiter rateLimiter, boolean stackTraceEnabled); }
RateLimitingTraceOptionsFactory implements TraceOptionsFactory { @Override public TraceOptions create() { boolean traceEnabled = rateLimiter.tryAcquire(); return new TraceOptions() .overrideTraceEnabled(traceEnabled) .overrideStackTraceEnabled(stackTraceEnabled); } RateLimitingTraceOptionsFactory(double samplingRate, boolean stackTraceEnabled); @VisibleForTesting  RateLimitingTraceOptionsFactory(RateLimiter rateLimiter, boolean stackTraceEnabled); @Override TraceOptions create(); @Override TraceOptions create(TraceOptions traceOptions); }
RateLimitingTraceOptionsFactory implements TraceOptionsFactory { @Override public TraceOptions create() { boolean traceEnabled = rateLimiter.tryAcquire(); return new TraceOptions() .overrideTraceEnabled(traceEnabled) .overrideStackTraceEnabled(stackTraceEnabled); } RateLimitingTraceOptionsFactory(double samplingRate, boolean stackTraceEnabled); @VisibleForTesting  RateLimitingTraceOptionsFactory(RateLimiter rateLimiter, boolean stackTraceEnabled); @Override TraceOptions create(); @Override TraceOptions create(TraceOptions traceOptions);  }