test_class.file: proxy/src/test/java/com/wavefront/common/SamplingLoggerTest.java
test_class.identifier: SamplingLoggerTest
test_case.body: @Test
    public void test25PercentSamplingThroughIsLoggable() {
      Logger mockLogger = EasyMock.createMock(Logger.class);
      reset(mockLogger);
      expect(mockLogger.getName()).andReturn("loggerName").anyTimes();
      expect(mockLogger.isLoggable(anyObject())).andReturn(true).anyTimes();
      replay(mockLogger);
      SamplingLogger testLog1 = new SamplingLogger(ReportableEntityType.POINT, mockLogger, 0.25,
          false, null);
      int count = 0;
      for (int i = 0; i < 1000; i++) {
        if (testLog1.isLoggable(Level.FINEST)) count++;
      }
      assertTrue(count < 300);
      assertTrue(count > 200);
      count = 0;
      for (int i = 0; i < 1000; i++) {
        if (testLog1.isLoggable(Level.FINER)) count++;
      }
      assertEquals(1000, count);
    }
test_case.class_method_signature: SamplingLoggerTest.test25PercentSamplingThroughIsLoggable()
test_case.full_signature: @Test public void test25PercentSamplingThroughIsLoggable()
test_case.identifier: test25PercentSamplingThroughIsLoggable
test_case.invocations: createMock reset anyTimes andReturn expect getName anyTimes andReturn expect isLoggable anyObject replay isLoggable assertTrue assertTrue isLoggable assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test25PercentSamplingThroughIsLoggable()
focal_class.declarator: RANDOM = new Random()
focal_class.modifier: private static final
focal_class.original_string: private static final Random RANDOM = new Random();
focal_class.type: Random
focal_class.var_name: RANDOM
focal_class.declarator: entityType
focal_class.modifier: private final
focal_class.original_string: private final ReportableEntityType entityType;
focal_class.type: ReportableEntityType
focal_class.var_name: entityType
focal_class.declarator: samplingRate
focal_class.modifier: private final
focal_class.original_string: private final double samplingRate;
focal_class.type: double
focal_class.var_name: samplingRate
focal_class.declarator: alwaysActive
focal_class.modifier: private final
focal_class.original_string: private final boolean alwaysActive;
focal_class.type: boolean
focal_class.var_name: alwaysActive
focal_class.declarator: statusChangeConsumer
focal_class.modifier: private final
focal_class.original_string: private final Consumer<String> statusChangeConsumer;
focal_class.type: Consumer<String>
focal_class.var_name: statusChangeConsumer
focal_class.declarator: loggingActive = new AtomicBoolean(false)
focal_class.modifier: private final
focal_class.original_string: private final AtomicBoolean loggingActive = new AtomicBoolean(false);
focal_class.type: AtomicBoolean
focal_class.var_name: loggingActive
focal_class.file: proxy/src/main/java/com/wavefront/common/SamplingLogger.java
focal_class.identifier: SamplingLogger
focal_class.class_method_signature: SamplingLogger.SamplingLogger(ReportableEntityType entityType,
                          Logger delegate,
                          double samplingRate,
                          boolean alwaysActive,
                          @Nullable Consumer<String> statusChangeConsumer)
focal_class.full_signature: public  SamplingLogger(ReportableEntityType entityType,
                          Logger delegate,
                          double samplingRate,
                          boolean alwaysActive,
                          @Nullable Consumer<String> statusChangeConsumer)
focal_class.identifier: SamplingLogger
focal_class.modifiers: public
focal_class.parameters: (ReportableEntityType entityType,
                          Logger delegate,
                          double samplingRate,
                          boolean alwaysActive,
                          @Nullable Consumer<String> statusChangeConsumer)
focal_class.signature:  SamplingLogger(ReportableEntityType entityType,
                          Logger delegate,
                          double samplingRate,
                          boolean alwaysActive,
                          @Nullable Consumer<String> statusChangeConsumer)
focal_class.class_method_signature: SamplingLogger.isLoggable(Level level)
focal_class.full_signature: @Override public boolean isLoggable(Level level)
focal_class.identifier: isLoggable
focal_class.modifiers: @Override public
focal_class.parameters: (Level level)
focal_class.return: boolean
focal_class.signature: boolean isLoggable(Level level)
focal_class.class_method_signature: SamplingLogger.log(Level level, String message)
focal_class.full_signature: @Override public void log(Level level, String message)
focal_class.identifier: log
focal_class.modifiers: @Override public
focal_class.parameters: (Level level, String message)
focal_class.return: void
focal_class.signature: void log(Level level, String message)
focal_class.class_method_signature: SamplingLogger.refreshLoggerState()
focal_class.full_signature: @VisibleForTesting void refreshLoggerState()
focal_class.identifier: refreshLoggerState
focal_class.modifiers: @VisibleForTesting
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void refreshLoggerState()
focal_class.superclass: extends DelegatingLogger
focal_method.body: @Override
    public boolean isLoggable(Level level) {
      if (level == Level.FINEST) {
        return (alwaysActive || loggingActive.get()) &&
            (samplingRate >= 1.0d || (samplingRate > 0.0d && RANDOM.nextDouble() < samplingRate));
      } else {
        return delegate.isLoggable(level);
      }
    }
focal_method.class_method_signature: SamplingLogger.isLoggable(Level level)
focal_method.full_signature: @Override public boolean isLoggable(Level level)
focal_method.identifier: isLoggable
focal_method.invocations: get nextDouble isLoggable
focal_method.modifiers: @Override public
focal_method.parameters: (Level level)
focal_method.return: boolean
focal_method.signature: boolean isLoggable(Level level)