zoukankan      html  css  js  c++  java
  • 附6 hystrix metrics and monitor

    一、基本方式

    • hystrix为每一个commandKey提供了计数器

    二、实现流程

    • https://raw.githubusercontent.com/wiki/Netflix/Hystrix/images/metrics-generation.png

    三、Hystrix event types

    1、什么情况下会触发fallback方法?

    2、fallback方法在什么情况下会抛出异常

    四、metrics storage

    1、实现原理

    • 当计数结果(metrics)产生之后,这些结果会在被推到其他系统中前存储一段时间。

    2、存储结构

    • hystrix会将计数结果存储在内存数据结构里(in-memory data structures)。这个数据结构在1.5.0之后进行了改变。

    2.1、高于1.4.x版本

    • HystrixRollingNumber记录events("三"中)的counts(HystrixCommandMetrics的父类HystrixMetrics的属性)
    • HystrixRollingPercentile记录感兴趣的分布的数量。例如:记录command的延迟,collapser的批量size。(HystrixCommandMetrics的属性)

    注意:

    • 当command执行时,计数结果会被同步写到如上的两个数据结构中。
    • 如果该command是多个线程在执行,HystrixRollingNumber和HystrixRollingPercentile内部会有一个同步逻辑来达到线程安全(我们不需要再外部去做线程安全处理)
    • 以上这两个数据结构支持滚动模型,即只保存最新的值(而metrics会根据配置保存多个值,比如保存每一秒的值)

    2.2、HystrixRollingNumber

    当执行一个command的时候,HystrixRollingNumber会被初始化

    五、metrics reads

    1、所有hystrix-contrib中的metrics publishers and streams可以从上述的数据结构中读取信息。

    2、数据结构只存储了最新的值,我们想看之前的值,只能通过分析HystrixRequestLog

    3、The HystrixRequestLog tracks all events in a request, and makes them available as a string。

    六、metrics event stream

    1、原理

    • 只要客户端连接还连着,hystrix-metrics-event-stream就会不断的向客户端以text/event-stream的形式推送计数结果(metrics)

    2、

    七、metrics publisher

  • 相关阅读:
    java 多线程小记
    Java通过反射实现实例化
    selenium webdriver 屏幕滚动
    selenium webdriver 实现百度贴吧自动签到
    selenium webdriver 小计
    JaveWeb 公司项目(7)----- 通过JS动态生成DIV
    两个DIV并排显示
    Intellij idea注册码失效
    JaveWeb 公司项目(6)----- 通过ToolTip给控件添加动态注释
    Intellij idea 添加浏览器
  • 原文地址:https://www.cnblogs.com/java-zhao/p/5813203.html
Copyright © 2011-2022 走看看