如何重置Dropwizard指标的计时器? [英] How can I reset timer of dropwizard metrics?
问题描述
我们正在处理定期收到的消息.我们使用codahale dropwizard指标的计时器"来衡量处理它们所需的时间.
We are processing messages that comes in periodically. We use codahale dropwizard metrics' "Timer" for measuring the time it takes to process them.
我发现有人在此处遇到相同的问题: 存储量呈指数递减的问题是,如果没有新数据输入,它将始终保持相同的数字.例如,假设您将计时器更新为5和7(那么就什么都不用了) ,那么无论您何时看到(即使在x小时后),计时器仍将显示平均值为6,无论如何均不能代表最近5分钟. 因此,仅当数据一直在到达时才有效."
I found someone had the same issue here: "problem with exponentially decaying reservoir is that if no new data comes in, it will keep on giving the same numbers all the times. For example, let say you update a timer with 5 and 7 (then don't put anything at all) , then no matter when you see (even after x hours), timer will still show the average to be 6 which is not representative of last 5 mins by any means. so, it works only if data is arriving all the time."
如深蓝色线所示:
但是没有解决的建议.他们说这将不会实现: https://github.com/dropwizard/metrics/Issues/399
But there's no suggestion to solve it. And they say it's not going to be implemented: https://github.com/dropwizard/metrics/issues/399
如何正确重置这些计时器,或者应该如何对其进行可视化处理,以免造成混淆?
How can I reset these timers properly or how should I visualize it so it's not confusing?
推荐答案
Note: It is too long for comment.
使用SlidingTimeWindowReservoir
将涵盖大多数用例.
但正如此评论中指出的那样,可能会出现问题,具体取决于事件数:
它将所有测量结果保存在内存窗口中,这在发生大量事件时变得不可接受
Using the SlidingTimeWindowReservoir
will cover most of the use-cases.
But as pointed out in this comment there could be a problem depending on the number of events:
it keeps all the measurements in the window in-memory which becomes unacceptable at large number of events
我们可以做得更好吗?让我们继续搜索.如果幸运的话,我们会找到此博客文章.它准确地描述了您的问题类型.有一个指向他们简单的肮脏解决方案的链接.另外建议使用 HdrHistogram .
Could we do better? Let's continue searching. If we are lucky we will find this blog post. It describes exactly your kind of problem. There is a link to their simple dirty solution. Also a suggestion for using HdrHistogram.
在指标邮件列表上,还有几条有关正是这个问题.
对于示例并指向 Marshall Pierce/hdrhistogram-metrics-reservoir .什么是HdrHistogram
?为什么要用它来测量延迟?请检查项目说明.
Also on the metrics mailing list there are several messages about exactly this problem.
For example and point to Marshall Pierce/hdrhistogram-metrics-reservoir. What is HdrHistogram
and why use it to measure latencies check the project description.
最后,在进一步挖掘之后,您还可以找到 vladimir-bukhtoyarov/metrics-core-hdr
项目.它也在使用HdrHistogram
.
And finally after some more digging you could find also vladimir-bukhtoyarov/metrics-core-hdr
project. It's using HdrHistogram
also.
因此,有两个类似的库使用相同的数据结构并声称可以解决您遇到的问题.
So there are two similar libraries that use the same data structure and claim to solve the problem case you have hit.
这篇关于如何重置Dropwizard指标的计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!