在 Spring 云 zuul 上获取电路的连接统计信息
Getting connections stats for circuits on Spring cloud zuul
我是 运行 一些微服务实例,它们充当边缘路由器并具有 @EnableZuulProxy 注释。我写了很多过滤器,它们控制着进入系统的请求流。
我想做的是从幕后发生的事情中获取电路统计数据。我看到有一个底层 netflix class DynamicServerListLoadBalancer 有一些我想看到的 sts。是否可以获取它的一个实例并在特定时间从它获取统计信息>
我可以看到它有这样的东西:(我格式化了我在日志中看到的日志语句)
c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client authserver initialized:
DynamicServerListLoadBalancer:{
NFLoadBalancer:
name=authserver,current
list of Servers=[127.0.0.1:9999],
Load balancer stats=
Zone stats: {
defaultzone=[
Zone:defaultzone;
Instance count:1;
Active connections count: 0;
Circuit breaker tripped count: 0;
Active connections per server: 0.0;]
},
Server stats:
[[
Server:127.0.0.1:9999;
Zone:defaultZone;
Total Requests:0;
Successive connection failure:0;
Total blackout seconds:0;
Last connection made:Wed Dec 31 19:00:00 EST 1969;
First connection made: Wed Dec 31 19:00:00 EST 1969;
Active Connections:0;
total failure count in last (1000) msecs:0;
average resp time:0.0; 9
0 percentile resp time:0.0;
95 percentile resp time:0.0;
min resp time:0.0;
max resp time:0.0;
stddev resp time:0.0
]]
}
ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@5b1b78aa
所有这些对于获得和采取行动都是有价值的。主要是将使用启发式反馈给系统。
好吧,就像大多数事情一样,我自己想出来了。
所以给你。
HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("what you are looking for");
HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(hystrixCommandKey);
HystrixCommandProperties properties = hystrixCommandMetrics.getProperties();
long maxConnections = properties.executionIsolationSemaphoreMaxConcurrentRequests().get().longValue();
boolean circuitOpen = properties.circuitBreakerForceOpen().get().booleanValue();
int currentConnections = hystrixCommandMetrics.getCurrentConcurrentExecutionCount();
所以在这个例子中,"what you are looking for" 就是你正在寻找的歇斯底里命令。
这为您提供了您正在寻找的特定歇斯底里事物的属性。
从中提取最大连接数、当前连接数以及电路是否打开。
原来如此。
我是 运行 一些微服务实例,它们充当边缘路由器并具有 @EnableZuulProxy 注释。我写了很多过滤器,它们控制着进入系统的请求流。
我想做的是从幕后发生的事情中获取电路统计数据。我看到有一个底层 netflix class DynamicServerListLoadBalancer 有一些我想看到的 sts。是否可以获取它的一个实例并在特定时间从它获取统计信息>
我可以看到它有这样的东西:(我格式化了我在日志中看到的日志语句)
c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client authserver initialized:
DynamicServerListLoadBalancer:{
NFLoadBalancer:
name=authserver,current
list of Servers=[127.0.0.1:9999],
Load balancer stats=
Zone stats: {
defaultzone=[
Zone:defaultzone;
Instance count:1;
Active connections count: 0;
Circuit breaker tripped count: 0;
Active connections per server: 0.0;]
},
Server stats:
[[
Server:127.0.0.1:9999;
Zone:defaultZone;
Total Requests:0;
Successive connection failure:0;
Total blackout seconds:0;
Last connection made:Wed Dec 31 19:00:00 EST 1969;
First connection made: Wed Dec 31 19:00:00 EST 1969;
Active Connections:0;
total failure count in last (1000) msecs:0;
average resp time:0.0; 9
0 percentile resp time:0.0;
95 percentile resp time:0.0;
min resp time:0.0;
max resp time:0.0;
stddev resp time:0.0
]]
}
ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@5b1b78aa
所有这些对于获得和采取行动都是有价值的。主要是将使用启发式反馈给系统。
好吧,就像大多数事情一样,我自己想出来了。
所以给你。
HystrixCommandKey hystrixCommandKey = HystrixCommandKey.Factory.asKey("what you are looking for");
HystrixCommandMetrics hystrixCommandMetrics = HystrixCommandMetrics.getInstance(hystrixCommandKey);
HystrixCommandProperties properties = hystrixCommandMetrics.getProperties();
long maxConnections = properties.executionIsolationSemaphoreMaxConcurrentRequests().get().longValue();
boolean circuitOpen = properties.circuitBreakerForceOpen().get().booleanValue();
int currentConnections = hystrixCommandMetrics.getCurrentConcurrentExecutionCount();
所以在这个例子中,"what you are looking for" 就是你正在寻找的歇斯底里命令。
这为您提供了您正在寻找的特定歇斯底里事物的属性。
从中提取最大连接数、当前连接数以及电路是否打开。
原来如此。