@Test void testCapacityWithoutTags() { MockClock testClock = new MockClock(); SimpleMeterRegistry meterRegistry = new SimpleMeterRegistry(); CapacityMonitor testSubject = CapacityMonitor.buildMonitor("1", meterRegistry, 1, TimeUnit.SECONDS, testClock); EventMessage<Object> foo = asEventMessage(1); EventMessage<Object> bar = asEventMessage("bar"); Map<? super Message<?>, MessageMonitor.MonitorCallback> callbacks = testSubject .onMessagesIngested(Arrays.asList(foo, bar)); testClock.addSeconds(1); callbacks.get(foo).reportSuccess(); callbacks.get(bar).reportFailure(null); Gauge capacityGauge = meterRegistry.get("1.capacity").gauge(); assertEquals(2, capacityGauge.value(), 0); }
public static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry) { return buildMonitor(meterNamePrefix, meterRegistry, 10, TimeUnit.MINUTES); }
CapacityMonitor implements MessageMonitor<Message<?>> { public static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry) { return buildMonitor(meterNamePrefix, meterRegistry, 10, TimeUnit.MINUTES); } }
CapacityMonitor implements MessageMonitor<Message<?>> { public static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry) { return buildMonitor(meterNamePrefix, meterRegistry, 10, TimeUnit.MINUTES); } private  CapacityMonitor(long window, TimeUnit timeUnit, Clock clock, String meterNamePrefix,
                            MeterRegistry meterRegistry); private  CapacityMonitor(long window, TimeUnit timeUnit, Clock clock, String meterNamePrefix,
                            MeterRegistry meterRegistry,
                            Function<Message<?>, Iterable<Tag>> tagsBuilder); }
CapacityMonitor implements MessageMonitor<Message<?>> { public static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry) { return buildMonitor(meterNamePrefix, meterRegistry, 10, TimeUnit.MINUTES); } private  CapacityMonitor(long window, TimeUnit timeUnit, Clock clock, String meterNamePrefix,
                            MeterRegistry meterRegistry); private  CapacityMonitor(long window, TimeUnit timeUnit, Clock clock, String meterNamePrefix,
                            MeterRegistry meterRegistry,
                            Function<Message<?>, Iterable<Tag>> tagsBuilder); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry,
                                               Function<Message<?>, Iterable<Tag>> tagsBuilder); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit, Function<Message<?>, Iterable<Tag>> tagsBuilder); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit, Clock clock); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit, Clock clock,
                                               Function<Message<?>, Iterable<Tag>> tagsBuilder); @Override MonitorCallback onMessageIngested(Message<?> message); }
CapacityMonitor implements MessageMonitor<Message<?>> { public static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry) { return buildMonitor(meterNamePrefix, meterRegistry, 10, TimeUnit.MINUTES); } private  CapacityMonitor(long window, TimeUnit timeUnit, Clock clock, String meterNamePrefix,
                            MeterRegistry meterRegistry); private  CapacityMonitor(long window, TimeUnit timeUnit, Clock clock, String meterNamePrefix,
                            MeterRegistry meterRegistry,
                            Function<Message<?>, Iterable<Tag>> tagsBuilder); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry,
                                               Function<Message<?>, Iterable<Tag>> tagsBuilder); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit, Function<Message<?>, Iterable<Tag>> tagsBuilder); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit, Clock clock); static CapacityMonitor buildMonitor(String meterNamePrefix, MeterRegistry meterRegistry, long window,
                                               TimeUnit timeUnit, Clock clock,
                                               Function<Message<?>, Iterable<Tag>> tagsBuilder); @Override MonitorCallback onMessageIngested(Message<?> message);  }