piggymetrics 微服务开源框架学习总结

目录

 

关于 gateway中提供统一端口访问时,请求外部服务如何处理

如何使用 feign client 调用外部服务

如果config 服务未接入注册中心的话,如果获取配置

如何使用config-server 在本地存储各个服务的配置文件以及如何提取公共配置

如何替换endpoint 采集服务的信息到turbine ,而是使用stream  比如  rabbitmq  ,客户端通过rabbitmq 发送数据,turbine消费服务状态数据


关于 gateway中提供统一端口访问时,请求外部服务如何处理

zuul:
  routes:
    auth-service:
      path: /uaa/**
      ###因为其没有在注册中心里面所以我们使用url 进行调转
      url: http://auth-service:5000
      stripPrefix: false
      sensitiveHeaders:

如何使用 feign client 调用外部服务

rates:
  url: https://api.exchangeratesapi.io
@FeignClient(url = "${rates.url}", name = "rates-client", fallback = ExchangeRatesClientFallback.class)
public interface ExchangeRatesClient {

    @RequestMapping(method = RequestMethod.GET, value = "/latest")
    ExchangeRatesContainer getRates(@RequestParam("base") Currency base);

}

如果config 服务未接入注册中心的话,如果获取配置

spring:
  cloud:
    config:
      uri: http://config:8888
      fail-fast: true
      password: ${CONFIG_SERVICE_PASSWORD}
      username: user

如何使用config-server 在本地存储各个服务的配置文件以及如何提取公共配置

spring:
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/shared
  profiles:
     active: native
公共配置提取为application,yml
标题

 

logging:
  level:
    org.springframework.security: INFO

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 10000

eureka:
  instance:
    prefer-ip-address: true
  client:
    serviceUrl:
      defaultZone: http://registry:8761/eureka/

 

如何替换endpoint 采集服务的信息到turbine ,而是使用stream  比如  rabbitmq  ,客户端通过rabbitmq 发送数据,turbine消费服务状态数据

服务端  和  客户端  需要添加依赖  ,服务端添加添加注解 @EnableTurbineStream即可

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

然后就可以直接使用hystrix-dashboard  进行集群或者单个服务的监控了 ,集群的话默默认使用服务实例id作为名称 ,default 的返回所有

https://my.turbine.sever:8989/turbine.stream?cluster=customers
https://my.turbine.sever:8989/turbine.stream?cluster=products
https://my.turbine.sever:8989/turbine.stream?cluster=default
https://my.turbine.sever:8989/turbine.stream

可以用如下配置实现自定义集群

turbine:
  appConfig: PRODUCT,ORDER
  clusterNameExpression: "'default'"

项目中如何使用sleuth 的,分为三种情况,只使用sleuth   和zipkin集成   及打印Logstash  JSON 格式通过 logback  供es 所使用

one by one

spring cloud sleuth 官方文档

只使用sleuth 

 参考该章节Only Sleuth (log correlation)

zipkin集成

参考该章节 Sleuth with Zipkin via HTTP

参考该章节 Sleuth with Zipkin over RabbitMQ or Kafka

打印Logstash  JSON 格式通过 logback

参考该章节  JSON Logback with Logstash

最后在补充一下sleuth 的实现原理

sleuth 实现机制
sleuth实现原理

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值