RpcServerMetricsCollector { public Timer.Context requestReceived (Object destination) { Timer specificMeter = metrics.getTimer(identifierPrefix, "requests", destination == null ? null : String.valueOf(destination)); totalNumberOfReceivedRequests.mark(); return specificMeter.time(); } RpcServerMetricsCollector(String identifier, Metrics metrics); Timer.Context requestReceived(Object destination); void requestCompleted(Timer.Context context, Object reply); void requestCompletedExceptionally(Timer.Context context, Object destination, Throwable error);  }
@Test void requestReceived() { sut.requestReceived("req1"); assertThat(metrics.getMeter("rpcServer.requests.total").getCount(), Matchers.is(1L)); assertThat(metrics.getTimer("rpcServer.requests.req1").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.completed.total").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.error.total").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.error.req1").getCount(), Matchers.is(0L)); }
@Test void requestReceivedWithNullDestinationPossible() { sut.requestReceived(null); assertThat(metrics.getMeter("rpcServer.requests.total").getCount(), Matchers.is(1L)); assertThat(metrics.getTimer("rpcServer.requests").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.completed.total").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.completed").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.error.total").getCount(), Matchers.is(0L)); assertThat(metrics.getMeter("rpcServer.error").getCount(), Matchers.is(0L)); }