@Test public void end_state_is_logged_and_accumulated() throws Exception { Map<MessageState, AtomicInteger> stateCounts = new EnumMap<>(MessageState.class); for (MessageState state : MessageState.values()) { stateCounts.put(state, new AtomicInteger()); } long count = 0; Random r = new Random(); while (count < 1000) { MessageState activeState = MessageState.values()[r.nextInt(MessageState.values().length)]; metrics.markMessageEndState(activeState); count++; stateCounts.get(activeState).getAndIncrement(); for (MessageState checkingState : MessageState.values()) { Counter metric = registry.counter("highwaypatrol-endState", singleton(Tag.of("state", checkingState.getMetricName()))); assertThat(metric.count(), is((double) stateCounts.get(checkingState).get())); } assertThat(registry.counter("highwaypatrol-messagesCounted").count(), is((double) count)); } }
public void markMessageEndState(MessageState state) { messagesCounted.increment(); messageEndStateReservoirs.get(state).increment(); }
MessagesMetricSet { public void markMessageEndState(MessageState state) { messagesCounted.increment(); messageEndStateReservoirs.get(state).increment(); } }
MessagesMetricSet { public void markMessageEndState(MessageState state) { messagesCounted.increment(); messageEndStateReservoirs.get(state).increment(); } MessagesMetricSet(MeterRegistry registry); }
MessagesMetricSet { public void markMessageEndState(MessageState state) { messagesCounted.increment(); messageEndStateReservoirs.get(state).increment(); } MessagesMetricSet(MeterRegistry registry); void markReceiverError(); void updateTransitTime(long transitTimeMs); void updateOnrampTime(long elaspedMs); void markMessageEndState(MessageState state); }
MessagesMetricSet { public void markMessageEndState(MessageState state) { messagesCounted.increment(); messageEndStateReservoirs.get(state).increment(); } MessagesMetricSet(MeterRegistry registry); void markReceiverError(); void updateTransitTime(long transitTimeMs); void updateOnrampTime(long elaspedMs); void markMessageEndState(MessageState state);  }