Fegin熔断
Sentinel 适配了 Feign 组件。如果想使用,除了引入 spring-cloud-starter-alibaba-sentinel 的依赖外还需要 2 个步骤:
- 配置文件打开 Sentinel 对 Feign 的支持:
feign.sentinel.enabled=true - 加入
spring-cloud-starter-openfeign依赖使 Sentinel starter 中的自动化配置类生效:
并修改TestClient如下:
@FeignClient(value = "hello-spring-cloud-alibaba-nacos-provider",fallbackFactory = TestClientImpl.class)
public interface TestClient {
@RequestMapping("/hi")
String sayHi(@RequestParam("msg")String msg);
}
@Component
public class TestClientImpl implements FallbackFactory<TestClient> {
@Override
public TestClient create(Throwable throwable) {
return new TestClient() {
@Override
public String sayHi(String msg) {
return "hi ,this is err!but you msg = "+msg+"! And you fail reason is "+throwable.getMessage();
}
};
}
}
再次重启项目并停止提供者服务访问http://localhost:8763/hi即可得到下面的熔断后结果:
hi ,this is err!but you msg = hello-spring-cloud-alibaba-nacos-feign-consumer! And you fail reason is com.netflix.client.ClientException: Load balancer does not have available server for client: hello-spring-cloud-alibaba-nacos-provider
Sentinel 控制台
1. 概述
Sentinel 提供一个轻量级的开源控制台,它提供机器发现以及健康情况管理、监控(单机和集群),规则管理和推送的功能。另外,鉴权在生产环境中也必不可少。这里,我们将会详细讲述如何通过简单的步骤就可以使用这些功能。
接下来,我们将会逐一介绍如何整合 Sentinel 核心库和 Dashboard,让它发挥最大的作用。同时我们也在阿里云上提供企业级的控制台:AHAS Sentinel 控制台,您只需要几个简单的步骤,就能最直观地看到控制台如何实现这些功能。
Sentinel 控制台包含如下功能:
- 查看机器列表以及健康情况:收集 Sentinel 客户端发送的心跳包,用于判断机器是否在线。
- 监控 (单机和集群聚合):通过 Sentinel 客户端暴露的监控 API,定期拉取并且聚合应用监控信息,最终可以实现秒级的实时监控。
- 规则管理和推送:统一管理推送规则。
- 鉴权:生产环境中鉴权非常重要。这里每个开发者需要根据自己的实际情况进行定制。
注意:Sentinel 控制台目前仅支持单机部署。
2. 启动控制台
2.1 获取 Sentinel 控制台
您可以从 release 页面 下载最新版本的控制台 jar 包。
您也可以从最新版本的源码自行构建 Sentinel 控制台:
- 下载 控制台 工程
- 使用以下命令将代码打包成一个 fat jar:
mvn clean package
2.2 启动
注意:启动 Sentinel 控制台需要 JDK 版本为 1.8 及以上版本。
使用如下命令启动控制台:
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
其中 -Dserver.port=8080 用于指定 Sentinel 控制台端口为 8080。
从 Sentinel 1.6.0 起,Sentinel 控制台引入基本的登录功能,默认用户名和密码都是 sentinel。可以参考 鉴权模块文档 配置用户名和密码。
用户可以通过如下参数进行配置:
-Dsentinel.dashboard.auth.username=sentinel用于指定控制台的登录用户名为sentinel;-Dsentinel.dashboard.auth.password=123456用于指定控制台的登录密码为123456;如果省略这两个参数,默认用户和密码均为sentinel;-Dserver.servlet.session.timeout=7200用于指定 Spring Boot 服务端 session 的过期时间,如7200表示 7200 秒;60m表示 60 分钟,默认为 30 分钟;
同样也可以直接在 Spring properties 文件中进行配置。
注意:部署多台控制台时,session 默认不会在各实例之间共享,这一块需要自行改造。
3. 客户端接入控制台
控制台启动后,客户端需要按照以下步骤接入到控制台。
针对于咱们的微服务,我们使用上面的fegin项目,我们直接在application.yml中加上
spring:
cloud:
sentinel:
transport:
port: 8719
dashboard: localhost:8080
这里的 spring.cloud.sentinel.transport.port 端口配置会在应用对应的机器上启动一个 Http Server,该 Server 会与 Sentinel 控制台做交互。比如 Sentinel 控制台添加了一个限流规则,会把规则数据 push 给这个 Http Server 接收,Http Server 再将规则注册到 Sentinel 中。
然后重启项目。
我们测试一下sentinel的流控功能:
我们对hi这个接口增加了QPS限制,一秒请求超过一次,我们看看会发生什么?
连续刷新我们的请求:http://localhost:8763/hi
被我们之前编写的熔断器中断了。
至此我们sentinel也成功集成了。
我们使用sentinel进行了熔断,也在控制台进行了流控,都是ok的,还有很多功能,有兴趣可以查阅官方文档
Spring Cloud Gateway
简介
Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
Spring Cloud Gateway旨在提供一种简单而有效的方法来路由到API,并为它们提供跨领域的关注,例如:安全性,监视/度量和弹性。
在之前我们已经使用过另外一个Zuul网关组件,这里我们就不在多说。
名词
- Route(路由):它是网关的基本构建单元。它由id、目标uri,谓词集合,过滤器集合组成。如果聚合谓词为true,则匹配路由。
- Predicate(谓词):这是Java 8函数谓词。输入类型是Spring Framework ServerWebExchange。这使您可以匹配HTTP请求中的所有内容,例如标头或参数。
- Filter(过滤器):这些是使用特定工厂构造的Spring Framework GatewayFilter实例。在这里,您可以在发送下游请求之前或之后修改请求和响应。
工作流程
客户端向Spring Cloud Gateway发出请求。如果网关处理程序映射确定请求与路由匹配,则将其发送到网关Web处理程序。该处理程序通过特定于请求的过滤器链运行请求。筛选器由虚线分隔的原因是,筛选器可以在发送代理请求之前和之后运行逻辑。所有“前置”过滤器逻辑均被执行。然后发出代理请求。发出代理请求后,将运行“后”过滤器逻辑。
在没有端口的路由中定义的URI,HTTP和HTTPS URI的默认端口值分别为80和443。
创建一个gateway的项目
pom.xml文件如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.wujie</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>hello-spring-cloud-alibaba-dependencies</artifactId>
</parent>
<groupId>com.wujie</groupId>
<artifactId>hello-spring-cloud-alibaba-nacos-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>hello-spring-cloud-alibaba-nacos-gateway</name>
<description>基于gateway创建网关</description>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.0.RELEASE</version>
<configuration>
<mainClass>
com.wujie.hello.spring.cloud.alibaba.nacos.gateway.HelloSpringCloudAlibabaNacosGatewayApplication
</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
application.yml
server:
port: 8765
spring:
application:
name: hello-spring-cloud-alibaba-nacos-gateway
cloud:
nacos:
discovery:
server-addr: localhost:8848
gateway:
routes:
- id: fegin
uri: lb://hello-spring-cloud-alibaba-nacos-feign-consumer
predicates:
- Path=/**
- id: rest
uri: lb://hello-spring-cloud-alibaba-nacos-rest-consumer
predicates:
- Path=/**
discovery:
locator:
lower-case-service-id:management: true
enabled: true
endpoints:
web:
exposure:
include: "*"
启动类上增加@EnableDiscoveryClient注解启动项目后,我们访问
http://localhost:8765/hello-spring-cloud-alibaba-nacos-rest-consumer/hi
http://localhost:8765/hello-spring-cloud-alibaba-nacos-feign-consumer/hi
得到这样的结果证明我们目前至少没有问题。但是我们发现,这个利用服务名去调用的方式实在太坑,太长,不方便啊。这是我们在application.yml中修改如下配置
- id: fegin
uri: lb://hello-spring-cloud-alibaba-nacos-feign-consumer
predicates:
- Path=/fegin/**
filters:
- StripPrefix=1
- id: rest
uri: lb://hello-spring-cloud-alibaba-nacos-rest-consumer
predicates:
- Path=/rest/**
filters:
- StripPrefix=1
再换成以下方式访问:
http://localhost:8765/fegin/hi
这样一对比,显然,第二种更好一些。
类似的配置还有很多,就不一一列举,谓词以及过滤器都还有很多的用法,有兴趣的可以自己查看 gateway 官网
附录:更多配置项
| Name | Default | Description |
|---|---|---|
| spring.cloud.gateway.default-filters | List of filter definitions that are applied to every route. | |
| spring.cloud.gateway.discovery.locator.enabled | false | Flag that enables DiscoveryClient gateway integration. |
| spring.cloud.gateway.discovery.locator.filters | ||
| spring.cloud.gateway.discovery.locator.include-expression | true | SpEL expression that will evaluate whether to include a service in gateway integration or not, defaults to: true. |
| spring.cloud.gateway.discovery.locator.lower-case-service-id | false | Option to lower case serviceId in predicates and filters, defaults to false. Useful with eureka when it automatically uppercases serviceId. so MYSERIVCE, would match /myservice/** |
| spring.cloud.gateway.discovery.locator.predicates | ||
| spring.cloud.gateway.discovery.locator.route-id-prefix | The prefix for the routeId, defaults to discoveryClient.getClass().getSimpleName() + "_". Service Id will be appended to create the routeId. | |
| spring.cloud.gateway.discovery.locator.url-expression | 'lb://'+serviceId | SpEL expression that create the uri for each route, defaults to: 'lb://'+serviceId. |
| spring.cloud.gateway.enabled | true | Enables gateway functionality. |
| spring.cloud.gateway.fail-on-route-definition-error | true | Option to fail on route definition errors, defaults to true. Otherwise, a warning is logged. |
| spring.cloud.gateway.filter.remove-hop-by-hop.headers | ||
| spring.cloud.gateway.filter.remove-hop-by-hop.order | ||
| spring.cloud.gateway.filter.request-rate-limiter.deny-empty-key | true | Switch to deny requests if the Key Resolver returns an empty key, defaults to true. |
| spring.cloud.gateway.filter.request-rate-limiter.empty-key-status-code | HttpStatus to return when denyEmptyKey is true, defaults to FORBIDDEN. | |
| spring.cloud.gateway.filter.secure-headers.content-security-policy | default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline' | |
| spring.cloud.gateway.filter.secure-headers.content-type-options | nosniff | |
| spring.cloud.gateway.filter.secure-headers.disable | ||
| spring.cloud.gateway.filter.secure-headers.download-options | noopen | |
| spring.cloud.gateway.filter.secure-headers.frame-options | DENY | |
| spring.cloud.gateway.filter.secure-headers.permitted-cross-domain-policies | none | |
| spring.cloud.gateway.filter.secure-headers.referrer-policy | no-referrer | |
| spring.cloud.gateway.filter.secure-headers.strict-transport-security | max-age=631138519 | |
| spring.cloud.gateway.filter.secure-headers.xss-protection-header | 1 ; mode=block | |
| spring.cloud.gateway.forwarded.enabled | true | Enables the ForwardedHeadersFilter. |
| spring.cloud.gateway.globalcors.add-to-simple-url-handler-mapping | false | If global CORS config should be added to the URL handler. |
| spring.cloud.gateway.globalcors.cors-configurations | ||
| spring.cloud.gateway.httpclient.connect-timeout | The connect timeout in millis, the default is 45s. | |
| spring.cloud.gateway.httpclient.max-header-size | The max response header size. | |
| spring.cloud.gateway.httpclient.max-initial-line-length | The max initial line length. | |
| spring.cloud.gateway.httpclient.pool.acquire-timeout | Only for type FIXED, the maximum time in millis to wait for aquiring. | |
| spring.cloud.gateway.httpclient.pool.max-connections | Only for type FIXED, the maximum number of connections before starting pending acquisition on existing ones. | |
| spring.cloud.gateway.httpclient.pool.max-idle-time | Time in millis after which the channel will be closed. If NULL, there is no max idle time. | |
| spring.cloud.gateway.httpclient.pool.max-life-time | Duration after which the channel will be closed. If NULL, there is no max life time. | |
| spring.cloud.gateway.httpclient.pool.name | proxy | The channel pool map name, defaults to proxy. |
| spring.cloud.gateway.httpclient.pool.type | Type of pool for HttpClient to use, defaults to ELASTIC. | |
| spring.cloud.gateway.httpclient.proxy.host | Hostname for proxy configuration of Netty HttpClient. | |
| spring.cloud.gateway.httpclient.proxy.non-proxy-hosts-pattern | Regular expression (Java) for a configured list of hosts. that should be reached directly, bypassing the proxy | |
| spring.cloud.gateway.httpclient.proxy.password | Password for proxy configuration of Netty HttpClient. | |
| spring.cloud.gateway.httpclient.proxy.port | Port for proxy configuration of Netty HttpClient. | |
| spring.cloud.gateway.httpclient.proxy.username | Username for proxy configuration of Netty HttpClient. | |
| spring.cloud.gateway.httpclient.response-timeout | The response timeout. | |
| spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout | 3000ms | SSL close_notify flush timeout. Default to 3000 ms. |
| spring.cloud.gateway.httpclient.ssl.close-notify-flush-timeout-millis | ||
| spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout | SSL close_notify read timeout. Default to 0 ms. | |
| spring.cloud.gateway.httpclient.ssl.close-notify-read-timeout-millis | ||
| spring.cloud.gateway.httpclient.ssl.default-configuration-type | The default ssl configuration type. Defaults to TCP. | |
| spring.cloud.gateway.httpclient.ssl.handshake-timeout | 10000ms | SSL handshake timeout. Default to 10000 ms |
| spring.cloud.gateway.httpclient.ssl.handshake-timeout-millis | ||
| spring.cloud.gateway.httpclient.ssl.key-password | Key password, default is same as keyStorePassword. | |
| spring.cloud.gateway.httpclient.ssl.key-store | Keystore path for Netty HttpClient. | |
| spring.cloud.gateway.httpclient.ssl.key-store-password | Keystore password. | |
| spring.cloud.gateway.httpclient.ssl.key-store-provider | Keystore provider for Netty HttpClient, optional field. | |
| spring.cloud.gateway.httpclient.ssl.key-store-type | JKS | Keystore type for Netty HttpClient, default is JKS. |
| spring.cloud.gateway.httpclient.ssl.trusted-x509-certificates | Trusted certificates for verifying the remote endpoint’s certificate. | |
| spring.cloud.gateway.httpclient.ssl.use-insecure-trust-manager | false | Installs the netty InsecureTrustManagerFactory. This is insecure and not suitable for production. |
| spring.cloud.gateway.httpclient.websocket.max-frame-payload-length | Max frame payload length. | |
| spring.cloud.gateway.httpclient.websocket.proxy-ping | true | Proxy ping frames to downstream services, defaults to true. |
| spring.cloud.gateway.httpclient.wiretap | false | Enables wiretap debugging for Netty HttpClient. |
| spring.cloud.gateway.httpserver.wiretap | false | Enables wiretap debugging for Netty HttpServer. |
| spring.cloud.gateway.loadbalancer.use404 | false | |
| spring.cloud.gateway.metrics.enabled | true | Enables the collection of metrics data. |
| spring.cloud.gateway.metrics.tags | Tags map that added to metrics. | |
| spring.cloud.gateway.redis-rate-limiter.burst-capacity-header | X-RateLimit-Burst-Capacity | The name of the header that returns the burst capacity configuration. |
| spring.cloud.gateway.redis-rate-limiter.config | ||
| spring.cloud.gateway.redis-rate-limiter.include-headers | true | Whether or not to include headers containing rate limiter information, defaults to true. |
| spring.cloud.gateway.redis-rate-limiter.remaining-header | X-RateLimit-Remaining | The name of the header that returns number of remaining requests during the current second. |
| spring.cloud.gateway.redis-rate-limiter.replenish-rate-header | X-RateLimit-Replenish-Rate | The name of the header that returns the replenish rate configuration. |
| spring.cloud.gateway.redis-rate-limiter.requested-tokens-header | X-RateLimit-Requested-Tokens | The name of the header that returns the requested tokens configuration. |
| spring.cloud.gateway.routes | List of Routes. | |
| spring.cloud.gateway.set-status.original-status-header-name | The name of the header which contains http code of the proxied request. | |
| spring.cloud.gateway.streaming-media-types | ||
| spring.cloud.gateway.x-forwarded.enabled | true | If the XForwardedHeadersFilter is enabled. |
| spring.cloud.gateway.x-forwarded.for-append | true | If appending X-Forwarded-For as a list is enabled. |
| spring.cloud.gateway.x-forwarded.for-enabled | true | If X-Forwarded-For is enabled. |
| spring.cloud.gateway.x-forwarded.host-append | true | If appending X-Forwarded-Host as a list is enabled. |
| spring.cloud.gateway.x-forwarded.host-enabled | true | If X-Forwarded-Host is enabled. |
| spring.cloud.gateway.x-forwarded.order | 0 | The order of the XForwardedHeadersFilter. |
| spring.cloud.gateway.x-forwarded.port-append | true | If appending X-Forwarded-Port as a list is enabled. |
| spring.cloud.gateway.x-forwarded.port-enabled | true | If X-Forwarded-Port is enabled. |
| spring.cloud.gateway.x-forwarded.prefix-append | true | If appending X-Forwarded-Prefix as a list is enabled. |
| spring.cloud.gateway.x-forwarded.prefix-enabled | true | If X-Forwarded-Prefix is enabled. |
| spring.cloud.gateway.x-forwarded.proto-append | true | If appending X-Forwarded-Proto as a list is enabled. |
| spring.cloud.gateway.x-forwarded.proto-enabled | true | If X-Forwarded-Proto is enabled. |
Zipkin链路追踪
使用Zipkin进行链路追踪,在想要追踪的项目里加上依赖,并在配置文件中加入配置
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
并在application.yml中添加配置
zipkin:
base-url: http://localhost:9411
Apache SkyWalking链路追踪
什么是SkyWalking?
一个开放源代码的可观察性平台,用于收集,分析,聚合和可视化来自服务和云本机基础结构的数据。SkyWalking提供了一种简便的方法来维护您的分布式系统的清晰视图,即使在整个云中也是如此。它是一种现代的APM,专门为基于云的基于容器的分布式系统而设计。
为什么使用SkyWalking
SkyWalking提供了用于在许多不同情况下观察和监视分布式系统的解决方案。首先,与传统方法一样,SkyWalking为服务提供自动仪器代理,例如Java,C#,Node.js,Go,PHP和Nginx LUA。(并呼吁提供Python和C ++ SDK贡献)。在多语言,持续部署的环境中,云原生基础架构变得越来越强大,但也越来越复杂。SkyWalking的服务网格接收器使SkyWalking能够从Istio / Envoy和Linkerd等服务网格框架接收遥测数据,从而使用户能够了解整个分布式系统。
SkyWalking为服务,服务实例,端点提供可观察性功能。服务,实例和端点这些术语在当今到处都有使用,因此值得在SkyWalking的上下文中定义它们的特定含义:
- Service:表示一组/一组工作负载,这些工作负载为传入请求提供相同的行为。您可以在使用乐器代理或SDK时定义服务名称。SkyWalking也可以使用您在Istio等平台中定义的名称。
- Service Instance:服务组中的每个单独工作负载都称为实例。就像Kubernetes中的Pod一样,它不必是单个OS进程,但是,如果您使用乐器代理,则实例实际上是一个真正的OS进程。
- Endpoint:服务中用于传入请求的路径,例如HTTP URI路径或gRPC服务类+方法签名
通过SkyWalking,用户可以了解服务和端点之间的拓扑关系,可以查看每个服务/服务实例/端点的指标并设置警报规则。
此外,您可以整合:
- 其他使用SkyWalking本机代理和SDK以及Zipkin,Jaeger和OpenCensus进行的分布式跟踪。
- 其他指标系统,例如Prometheus,Sleuth(Micrometer)。
架构
从逻辑上讲,SkyWalking分为四个部分:探针,平台后端,存储和UI
- Probes 收集数据并重新格式化以符合SkyWalking的要求(不同的探针支持不同的来源)。
- Platform backend支持数据聚合,分析并推动从探针到UI的流程。该分析包括SkyWalking本机跟踪和度量标准,包括Istio和Envoy遥测在内的第三方,Zipkin跟踪格式等。您甚至可以通过使用针对本机度量标准的Observability Analysis Language和针对扩展度量标准的Meter System来定制聚合和分析。
- Storage 通过开放/可插入的界面存储SkyWalking数据。您可以选择现有的实现,例如ElasticSearch,H2或由Sharding-Sphere管理的MySQL集群,也可以实现自己的实现。
- UI一个高度可定制的基于Web的界面,允许SkyWalking最终用户可视化和管理SkyWalking数据。
快速开始
下载
官方已经为我们准备好了编译过的服务端版本,下载地址为 skywalking.apache.org/downloads/
启动 SkyWalking
直接进入bin目录运行startup.bat
各服务配置
我们需要使用官方提供的探针为我们达到监控的目的,按照实际情况我们需要实现三种部署方式
- IDEA 部署探针
- Java 启动方式部署探针(我们是 Spring Boot 应用程序,需要使用
java -jar的方式启动应用) - Docker 启动方式部署探针(暂时没有去做,有兴趣的可以自行测试)
探针文件在下好的agent目录
我们这里使用idea的方式去实现
在我们的项目中新建一个文件夹存放我们的agent文件中的所有文件夹以及文件
在我们所需要的项目中配置修改项目的 VM 运行参数,点击菜单栏中的 Run -> EditConfigurations...,此处我们以 hello-spring-cloud-alibaba-nacos-provider 项目为例,修改参数如下
-javaagent:D:\workspace\hello-spring-cloud-alibaba-dependencies\hello-spring-cloud-external-skywalking\agent\skywalking-agent.jar
-Dskywalking.agent.service_name=nacos-provider
-Dskywalking.collector.backend_service=localhost:11800
-javaagent:用于指定探针路径-Dskywalking.agent.service_name:用于重写agent/config/agent.config配置文件中的服务名-Dskywalking.collector.backend_service:用于重写agent/config/agent.config配置文件中的服务地址
启动项目可以在控制台看见如下日志:
DEBUG 2020-09-07 18:45:47:972 main AgentPackagePath : The beacon class location is jar:file:/D:/workspace/hello-spring-cloud-alibaba-dependencies/hello-spring-cloud-external-skywalking/agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class.
INFO 2020-09-07 18:45:47:974 main SnifferConfigInitializer : Config file found in D:\workspace\hello-spring-cloud-alibaba-dependencies\hello-spring-cloud-external-skywalking\agent\config\agent.config.
18:45:51.274 [SkywalkingAgent-5-GRPCChannelManager-0] DEBUG org.apache.skywalking.apm.dependencies.io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
访问之前编写的测试的url:http://localhost:8081/hi?msg=testSkyWalking
返回到SkyWalking的UI界面可以监控到我们的服务了
包含了我们的各种信息,至此SkyWalking的简直使用以及配置也就是完成了。还有很多本人也还不熟悉,只能是简单会用,在以后的学习中会经常记录下来,并分享。如有不足,还请大家指出。
总结与心得
从网上找了一张图:
这图很清楚的表明SpringCloud已经有很多组件进入了维护期:
Zuul、Ribbon、Hystrix、HystrixDashboard、Turbine、Turbine Stream这些组件都已经进入了维护期。
相比之下,alibaba的很多组件性能更好,感知更快。搭建也更加简单,最主要还是中文文档,这对国内的大多数玩家来说简直就是福音啊。如果之前觉得学习SpringCloud看英文很痛苦甚至不想看的同学来说,现在中文的还不愿意看,那就趁早转行吧。先撸一把文档,再跟着文档动手操作一次,出现的问题再解决,这样我们对每一个组件都至少用过三遍,不说精通,至少能够从0入门了吧。技术是要不断的摸索,不断的实践,不能一直原地踏步。
古人云温故而知新可以为师矣