首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Spring Cloud【Finchley】-11Feign项目整合Hystrix监控

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

作者头像
小小工匠
发布2021-08-17 15:38:02
发布2021-08-17 15:38:02
4270
举报
文章被收录于专栏:小工匠聊架构小工匠聊架构

文章目录

概述

我们前面的文章 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

代码语言:javascript
复制
<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中开启端点

代码语言:javascript
复制
#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. 测试

  1. 启动microservice-discovery-eureka,注册中心
  2. 启动micorservice-provider-user,服务提供者
  3. 启动micorservice-consumer-movie-feign-hystrix
  4. 访问 http://localhost:7901/actuator/hystrix.stream ,如下
  1. 访问下 http://localhost:7901/movie/3 触发hystrix收集信息
  2. 重新观察 http://localhost:7901/actuator/hystrix.stream

代码

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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018/12/27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • 概述
  • 整合步骤
    • Step1.添加 spring-cloud-starter-netflix-hystrix
    • Step2. 启动类增加@EnableCircuitBreaker或者@EnableHystrix注解
    • Step3. 引入spring-boot-starter-actuator并开启端点
    • Step4. 测试
  • 代码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档