FunctionStatsImpl implements FunctionStats { @Override public void close() { meterRegistry.remove(successTimer); successTimer.close(); meterRegistry.remove(failureTimer); failureTimer.close(); statistics.close(); isClosed.set(true); } FunctionStatsImpl(String functionId, MeterRegistry meterRegistry, Statistics statistics,
      FunctionServiceStats functionServiceStats); @VisibleForTesting  FunctionStatsImpl(String functionId, MeterRegistry meterRegistry, Statistics statistics,
      FunctionServiceStats aggregateStatistics, long clockResult,
      boolean timeStatisticsEnabledResult); @VisibleForTesting  FunctionStatsImpl(String functionId, MeterRegistry meterRegistry, Statistics statistics,
      FunctionServiceStats aggregateStatistics, long clockResult,
      boolean timeStatisticsEnabledResult, Timer successTimerResult, Timer registerFailureResult); private  FunctionStatsImpl(String functionId, MeterRegistry meterRegistry, Statistics statistics,
      FunctionServiceStats aggregateStatistics, LongSupplier clock,
      BooleanSupplier timeStatisticsEnabled,
      BiFunction<String, MeterRegistry, Timer> registerSuccessTimerFunction,
      BiFunction<String, MeterRegistry, Timer> registerFailureTimerFunction); @Override void close(); @Override boolean isClosed(); @Override int getFunctionExecutionsCompleted(); @Override int getFunctionExecutionsRunning(); @Override void incResultsReturned(); @Override int getResultsReceived(); @Override void incResultsReceived(); @Override int getFunctionExecutionCalls(); @Override long startFunctionExecution(boolean haveResult); @Override void endFunctionExecution(long startTime, boolean haveResult); @Override void endFunctionExecutionWithException(long startTime, boolean haveResult); @Override @VisibleForTesting Statistics getStatistics(); @Override @VisibleForTesting MeterRegistry getMeterRegistry(); static StatisticsType getStatisticsType();  }
@Test public void close_removesSuccessTimer() { FunctionStats functionStats = new FunctionStatsImpl(FUNCTION_ID, meterRegistry, statistics, functionServiceStats); functionStats.close(); assertThat(successTimer()) .as("geode.function.executions timer with tags function=%s, succeeded=true", FUNCTION_ID) .isNull(); }
@Test public void close_removesFailureTimer() { FunctionStats functionStats = new FunctionStatsImpl(FUNCTION_ID, meterRegistry, statistics, functionServiceStats); functionStats.close(); assertThat(failureTimer()) .as("geode.function.executions timer with tags function=%s, succeeded=false", FUNCTION_ID) .isNull(); }
@Test public void close_closesTimers() { Timer successTimer = mock(Timer.class); Timer failureTimer = mock(Timer.class); FunctionStats functionStats = new FunctionStatsImpl(FUNCTION_ID, mock(MeterRegistry.class), statistics, functionServiceStats, 0L, false, successTimer, failureTimer); functionStats.close(); verify(successTimer).close(); verify(failureTimer).close(); }
@Test public void close_closesStats() { FunctionStats functionStats = new FunctionStatsImpl(FUNCTION_ID, meterRegistry, statistics, functionServiceStats); functionStats.close(); verify(statistics).close(); }