@Test
public void monitorFailuresForSpecificMetastore() throws Throwable {
CurrentMonitoredMetaStoreHolder.monitorMetastore("metastoreName");
when(pjp.proceed()).thenThrow(new ClassCastException());
try {
aspect.monitor(pjp, monitored);
} catch (ClassCastException e) {
// Expected
}
ArgumentCaptor<String> metricCaptor = ArgumentCaptor.forClass(String.class);
verify(counterService, times(2)).increment(metricCaptor.capture());
assertThat(metricCaptor.getAllValues().get(0), is("counter.Type_Anonymous.myMethod.metastoreName.calls"));
assertThat(metricCaptor.getAllValues().get(1), is("counter.Type_Anonymous.myMethod.metastoreName.failure"));
metricCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<Long> durationCaptor = ArgumentCaptor.forClass(Long.class);
verify(gaugeService).submit(metricCaptor.capture(), durationCaptor.capture());
assertThat(metricCaptor.getValue(), is("timer.Type_Anonymous.myMethod.metastoreName.duration"));
}
MonitoredAspectTest.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:waggle-dance
作者:
评论列表
文章目录