You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "songxiaosheng (via GitHub)" <gi...@apache.org> on 2023/05/04 11:09:34 UTC

[GitHub] [dubbo] songxiaosheng commented on pull request #12223: degist-concurrency-bugfix

songxiaosheng commented on PR #12223:
URL: https://github.com/apache/dubbo/pull/12223#issuecomment-1534575866

   是否可以考虑比micrometer的滑动窗口函数,来实现相同的功能
   Micrometer是一个度量库,它提供了许多度量指标,包括计数器、计时器、直方图等等,可以用于监控应用程序的性能和健康状况。而滑动窗口是一种常用的度量指标的实现方式,它可以用来统计一段时间内的度量指标数据,比如最近一分钟、最近一小时等等。
   
   
   Micrometer提供了一个名为SlidingWindow的滑动窗口实现,可以用来统计一段时间内的度量指标数据。该实现可以通过以下方式创建:
   
   
   java
   Copy code
   SlidingWindow slidingWindow = new SlidingWindow(TimeUnit.SECONDS, 10);
   
   这里创建了一个10秒的滑动窗口。可以使用record方法向滑动窗口中添加度量指标数据,例如:
   
   
   java
   Copy code
   Counter counter = Counter.builder("my.counter").register(registry);
   slidingWindow.record(counter::count);
   
   这里创建了一个名为my.counter的计数器,并将其记录到滑动窗口中。可以使用stream方法获取滑动窗口中的度量指标数据,例如:
   
   
   java
   Copy code
   List<Double> measurements = slidingWindow.stream().map(Measurement::getValue).collect(Collectors.toList());
   
   这里获取了滑动窗口中所有度量指标数据的值,并将其存储在一个List中。可以根据需要对这些数据进行进一步处理,例如计算平均值、最大值、最小值等等。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org