FeignOutboundMetricsMethodHandlerTest.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:metrics-feign 作者:
@Test(expected = FeignException.class)
public void exception() {
    stubFor(post(anyUrl()).willReturn(aResponse().withStatus(400)));
    MyClientWithAnnotationOnMethodLevel target = Feign.builder().invocationHandlerFactory(
            new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry))
            .target(MyClientWithAnnotationOnMethodLevel.class,
                    String.format("http://localhost:%d", wireMockRule.port()));
    try {
        target.myMethod();
    } finally {

        assertMetrics();

        Set<Map.Entry<String, Meter>> entries = metricRegistry.getMeters().entrySet();

        entries.forEach(entry -> {
            if (entry.getKey().endsWith(ExceptionMetered.DEFAULT_NAME_SUFFIX)) {
                assertEquals(String.format("wrong number of invocations in metric %s", entry.getKey()), 1,
                        entry.getValue().getCount());
            }
        });
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号