- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每当我们的代码抛出com.netflix.hystrix.exception.HystrixRuntimeException: MyClass timed-out andfallback failed.
的异常时,我们总是必须重新猜测自己是否问题是 Hystrix 配置正确。我们可以回答这个问题的一个简单方法是,日志是否显示 Hystrix 线程在出错之前运行了多长时间。这样,如果它说 1000ms,我们就知道 Hystrix 没有正确配置(因为这是默认值),如果它说 5000ms,我们就知道它是按照我们想要的方式配置的。
最佳答案
你可以这样做:
command.getExecutionTimeInMilliseconds()
此方法告诉您 run 方法花费了多少秒,要捕获超时,您可以将其包装在命令类中的 try catch 中
@Override
protected HttpResponse run() throws Exception {
try {
return executeSomeCall();
} catch (Exception e) {
System.out.println(getExecutionTimeInMilliseconds());
throw e;
}
}
或在调用时在其外部
try {
HttpResponse response = command.execute();
return response;
}
catch (HystrixRuntimeException e) {
command.getExecutionTimeInMilliseconds() // do something with the info
}
只有一点,如果你使用Threads策略是可以的,但是如果你使用Semaphor,只有在得到响应后才会发生超时。即使你的超时是 1000 毫秒,而请求花费了 5000 毫秒。 hystryx 将等待 5000 毫秒给您一个超时错误,并且 getExecutionTimeInMilliseconds 将返回 1000 毫秒给您。
关于java - 当hystrix超时时,如何打印所花费的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38515439/
我一直在读一本分配给类(class)的书,它提到数组访问需要 O(1) 时间。我意识到这非常快(也许尽可能快),但是如果您有一个循环必须多次引用它,那么分配一个临时变量以在数组中查找值有什么好处吗?或
我一直试图找出为什么这个查询花了这么长时间。以前,它的执行时间约为 150 毫秒到 200 毫秒,但现在需要 25 秒或更长时间。这是从昨晚到今天之间的事。唯一改变的就是将数据添加到表中。 根据下面的
我有一个 ng repeat 重复数据。 - data.image(src)部分为null,src=null的不再重复。 我用一个简单的 ng-if 解决了它。
我有一个包含大量测试的 Laravel 项目。我正在使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但是 pcov 不支持分支覆盖,所以我决定使用 xdebug。 使用 xdebug 测试执行,
我已经被这个问题困扰了一段时间了,我被难住了。 Automapper 需要 4 秒来映射 19 个对象。在我的机器(24GB 内存,3.6Ghz i7)上,该操作应该花费毫秒或纳秒。 这是映射调用。
我有一个包含大量测试的 Laravel 项目。我正在使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但是 pcov 不支持分支覆盖,所以我决定使用 xdebug。 使用 xdebug 测试执行,
我在机器 A 上有一个 java 进程通过 TCP 与机器 B 上的 Tomcat 通信。 TCP 连接(只是 syn-syn/ack 交换)始终需要 100 毫秒的数量级,而 ping 请求需要 1
我做了一项任务,从 sqlserver 获取超过 200 万条记录并将它们填充到 Asp.net GridView 中。 问题是,查询需要超过 2 分钟才能获得记录,而我的查询现在已经完全优化。 当我
我希望将 165 秒变成 2:40 而不是 0:2:45 函数需要能够适应秒值的大小。 我知道有无数种方法可以做到这一点,但我正在寻找一种干净的方法来做到这一点,除了 jQuery 之外没有任何外部库
我是一名优秀的程序员,十分优秀!