### Question:
DebugMetrics implements JsonRpcMethod { @Override public String getName() { return RpcMethod.DEBUG_METRICS.getMethodName(); } DebugMetrics(final ObservableMetricsSystem metricsSystem); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldHaveCorrectName() { assertThat(method.getName()).isEqualTo("debug_metrics"); }
@Test public void shouldReportUnlabelledObservationsByCategory() { when(metricsSystem.streamObservations()) .thenReturn( Stream.of( new Observation(PEERS, "peer1", "peer1Value", Collections.emptyList()), new Observation(PEERS, "peer2", "peer2Value", Collections.emptyList()), new Observation(RPC, "rpc1", "rpc1Value", Collections.emptyList()))); assertResponse( ImmutableMap.of( PEERS.getName(), ImmutableMap.<String, Object>of("peer1", "peer1Value", "peer2", "peer2Value"), RPC.getName(), ImmutableMap.<String, Object>of("rpc1", "rpc1Value"))); }
@Test public void shouldNestObservationsByLabel() { when(metricsSystem.streamObservations()) .thenReturn( Stream.of( new Observation(PEERS, "peer1", "value1", asList("label1A", "label2A")), new Observation(PEERS, "peer1", "value2", asList("label1A", "label2B")), new Observation(PEERS, "peer1", "value3", asList("label1B", "label2B")))); assertResponse( ImmutableMap.of( PEERS.getName(), ImmutableMap.<String, Object>of( "peer1", ImmutableMap.of( "label1A", ImmutableMap.of("label2A", "value1", "label2B", "value2"), "label1B", ImmutableMap.of("label2B", "value3"))))); }