日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring Cloud【Finchley】-11Feign项目整合Hystrix监控

發布時間:2025/3/21 javascript 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Cloud【Finchley】-11Feign项目整合Hystrix监控 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 概述
  • 整合步驟
    • Step1.添加 spring-cloud-starter-netflix-hystrix
    • Step2. 啟動類增加@EnableCircuitBreaker或者@EnableHystrix注解
    • Step3. 引入spring-boot-starter-actuator并開啟端點
    • Step4. 測試
  • 代碼

概述

我們前面的文章 Spring Cloud【Finchley】-09Feign使用Hystrix 中介紹了,如何在使用Feign的項目中使用Hystrix, 現在來探討下如何在使用Feign的項目中監控Hystrix.


整合步驟

我們知道Hystrix的hystrix-metrics-event-stream模塊 將監控信息以text/event-stream的格式暴露給外部系統。

根據spring cloud的套路來講,一般都是 添加starter依賴,增加注解,使用

我們在原有工程中的依賴也沒有找到hystrix-metrics-event-stream該依賴

所以步驟一就是添加starter依賴

Step1.添加 spring-cloud-starter-netflix-hystrix

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency>

Step2. 啟動類增加@EnableCircuitBreaker或者@EnableHystrix注解

Step3. 引入spring-boot-starter-actuator并開啟端點

spring-boot-starter-actuator是必不可少的

application.yml中開啟端點

#actuator 啟用所有的監控端點 “*”號代表啟用所有的監控端點,可以單獨啟用,例如,health,info,metrics # spring boot 升為 2.0 后,為了安全,默認 Actuator 只暴露了2個端點,heath 和 info,繼續 # 訪問 http://192.168.1.103:7901/actuator/metrics management:endpoints:web:exposure:include: "*" endpoint:health:show-details: ALWAYS


Step4. 測試

  • 啟動microservice-discovery-eureka,注冊中心
  • 啟動micorservice-provider-user,服務提供者
  • 啟動micorservice-consumer-movie-feign-hystrix
  • 訪問 http://localhost:7901/actuator/hystrix.stream ,如下
  • 訪問下 http://localhost:7901/movie/3 觸發hystrix收集信息
  • 重新觀察 http://localhost:7901/actuator/hystrix.stream

  • 代碼

    https://github.com/yangshangwei/SpringCloudMaster/tree/master/micorservice-consumer-movie-fegin-hystrix

    總結

    以上是生活随笔為你收集整理的Spring Cloud【Finchley】-11Feign项目整合Hystrix监控的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。