Browse Source

Enhancement/normalize metric field (#170)

normalize metric fields and methods:
- rename exception to exceptionQps;
- remove ed postfix of all fields and methods about metrics;
master
李豪 GitHub 6 years ago
parent
commit
03922dbf6c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 235 additions and 238 deletions
  1. +3
    -3
      sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcClientInterceptorTest.java
  2. +3
    -3
      sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcServerInterceptorTest.java
  3. +6
    -6
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/Context.java
  4. +7
    -7
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/DefaultNode.java
  5. +4
    -4
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/EntranceNode.java
  6. +8
    -8
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java
  7. +7
    -7
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/StatisticNode.java
  8. +32
    -32
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricNode.java
  9. +3
    -3
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/StatisticSlot.java
  10. +3
    -3
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/metric/ArrayMetric.java
  11. +28
    -31
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/MetricEntity.java
  12. +18
    -18
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/domain/ResourceTreeNode.java
  13. +6
    -6
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/metric/MetricFetcher.java
  14. +5
    -5
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java
  15. +30
    -30
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/MetricVo.java
  16. +21
    -21
      sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/ResourceVo.java
  17. +11
    -11
      sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js
  18. +4
    -4
      sentinel-dashboard/src/main/webapp/resources/app/views/identity.html
  19. +2
    -2
      sentinel-dashboard/src/main/webapp/resources/app/views/metric.html
  20. +2
    -2
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchClusterNodeHumanCommandHandler.java
  21. +4
    -4
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchOriginCommandHandler.java
  22. +1
    -1
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchSystemStatusCommandHandler.java
  23. +6
    -6
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchTreeCommandHandler.java
  24. +21
    -21
      sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/vo/NodeVo.java

+ 3
- 3
sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcClientInterceptorTest.java View File

@@ -66,14 +66,14 @@ public class SentinelGrpcClientInterceptorTest {
ClusterNode clusterNode = ClusterBuilderSlot.getClusterNode(resourceName, EntryType.OUT);
assertNotNull(clusterNode);

assertEquals((total - threshold) / 2, clusterNode.blockedRequest());
assertEquals((total - threshold) / 2, clusterNode.blockRequest());
assertEquals(total / 2, clusterNode.totalRequest());

long totalQps = clusterNode.totalQps();
long passQps = clusterNode.passQps();
long blockedQps = clusterNode.blockedQps();
long blockQps = clusterNode.blockQps();
assertEquals(total, totalQps);
assertEquals(total - threshold, blockedQps);
assertEquals(total - threshold, blockQps);
assertEquals(threshold, passQps);

server.stop();


+ 3
- 3
sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcServerInterceptorTest.java View File

@@ -68,14 +68,14 @@ public class SentinelGrpcServerInterceptorTest {
ClusterNode clusterNode = ClusterBuilderSlot.getClusterNode(resourceName, EntryType.IN);
assertNotNull(clusterNode);

assertEquals((total - threshold) / 2, clusterNode.blockedRequest());
assertEquals((total - threshold) / 2, clusterNode.blockRequest());
assertEquals(total / 2, clusterNode.totalRequest());

long totalQps = clusterNode.totalQps();
long passQps = clusterNode.passQps();
long blockedQps = clusterNode.blockedQps();
long blockQps = clusterNode.blockQps();
assertEquals(total, totalQps);
assertEquals(total - threshold, blockedQps);
assertEquals(total - threshold, blockQps);
assertEquals(threshold, passQps);

server.stop();


+ 6
- 6
sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/Context.java View File

@@ -139,15 +139,15 @@ public class Context {
return getOriginNode() == null ? 0 : getOriginNode().totalQps();
}

public double getOriginBlockedQps() {
return getOriginNode() == null ? 0 : getOriginNode().blockedQps();
public double getOriginBlockQps() {
return getOriginNode() == null ? 0 : getOriginNode().blockQps();
}

public double getOriginPassedReqQps() {
public double getOriginPassReqQps() {
return getOriginNode() == null ? 0 : getOriginNode().successQps();
}

public double getOriginPassedQps() {
public double getOriginPassQps() {
return getOriginNode() == null ? 0 : getOriginNode().passQps();
}

@@ -155,8 +155,8 @@ public class Context {
return getOriginNode() == null ? 0 : getOriginNode().totalRequest();
}

public long getOriginBlockedRequest() {
return getOriginNode() == null ? 0 : getOriginNode().blockedRequest();
public long getOriginBlockRequest() {
return getOriginNode() == null ? 0 : getOriginNode().blockRequest();
}

public double getOriginAvgRt() {


+ 7
- 7
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/DefaultNode.java View File

@@ -88,9 +88,9 @@ public class DefaultNode extends StatisticNode {
}

@Override
public void increaseBlockedQps() {
super.increaseBlockedQps();
this.clusterNode.increaseBlockedQps();
public void increaseBlockQps() {
super.increaseBlockQps();
this.clusterNode.increaseBlockQps();
}

@Override
@@ -134,13 +134,13 @@ public class DefaultNode extends StatisticNode {
if (!(node instanceof EntranceNode)) {
System.out.println(
String.format("%s(thread:%s pq:%s bq:%s tq:%s rt:%s 1mp:%s 1mb:%s 1mt:%s)", node.id.getShowName(),
node.curThreadNum(), node.passQps(), node.blockedQps(), node.totalQps(), node.avgRt(),
node.totalRequest() - node.blockedRequest(), node.blockedRequest(), node.totalRequest()));
node.curThreadNum(), node.passQps(), node.blockQps(), node.totalQps(), node.avgRt(),
node.totalRequest() - node.blockRequest(), node.blockRequest(), node.totalRequest()));
} else {
System.out.println(
String.format("Entry-%s(t:%s pq:%s bq:%s tq:%s rt:%s 1mp:%s 1mb:%s 1mt:%s)", node.id.getShowName(),
node.curThreadNum(), node.passQps(), node.blockedQps(), node.totalQps(), node.avgRt(),
node.totalRequest() - node.blockedRequest(), node.blockedRequest(), node.totalRequest()));
node.curThreadNum(), node.passQps(), node.blockQps(), node.totalQps(), node.avgRt(),
node.totalRequest() - node.blockRequest(), node.blockRequest(), node.totalRequest()));
}
for (Node n : node.getChildList()) {
DefaultNode dn = (DefaultNode)n;


+ 4
- 4
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/EntranceNode.java View File

@@ -54,19 +54,19 @@ public class EntranceNode extends DefaultNode {
}

@Override
public long blockedQps() {
public long blockQps() {
int blockQps = 0;
for (Node node : getChildList()) {
blockQps += node.blockedQps();
blockQps += node.blockQps();
}
return blockQps;
}

@Override
public long blockedRequest() {
public long blockRequest() {
long r = 0;
for (Node node : getChildList()) {
r += node.blockedRequest();
r += node.blockRequest();
}
return r;
}


+ 8
- 8
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java View File

@@ -29,7 +29,7 @@ import com.alibaba.csp.sentinel.node.metric.MetricNode;
public interface Node {

/**
* Get incoming request per minute. {@code pass + blocked}
* Get incoming request per minute. {@code pass + block}
*/
long totalRequest();

@@ -41,9 +41,9 @@ public interface Node {
long totalSuccess();

/**
* Get blocked request count per minute.
* Get block request count per minute.
*/
long blockedRequest();
long blockRequest();

/**
* Get exception count per minute.
@@ -56,12 +56,12 @@ public interface Node {
long passQps();

/**
* Get blocked request per second.
* Get block request per second.
*/
long blockedQps();
long blockQps();

/**
* Get {@link #passQps()} + {@link #blockedQps()} request per second.
* Get {@link #passQps()} + {@link #blockQps()} request per second.
*/
long totalQps();

@@ -90,7 +90,7 @@ public interface Node {
int curThreadNum();

/**
* Get last second blocked QPS.
* Get last second block QPS.
*/
long previousBlockQps();

@@ -110,7 +110,7 @@ public interface Node {
*/
void rt(long rt);

void increaseBlockedQps();
void increaseBlockQps();

void increaseExceptionQps();



+ 7
- 7
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/StatisticNode.java View File

@@ -53,10 +53,10 @@ public class StatisticNode implements Node {
long newLastFetchTime = lastFetchTime;
for (MetricNode node : nodesOfEverySecond) {
if (node.getTimestamp() > lastFetchTime && node.getTimestamp() < currentTime) {
if (node.getPassedQps() != 0
|| node.getBlockedQps() != 0
if (node.getPassQps() != 0
|| node.getBlockQps() != 0
|| node.getSuccessQps() != 0
|| node.getException() != 0
|| node.getExceptionQps() != 0
|| node.getRt() != 0) {
metrics.put(node.getTimestamp(), node);
newLastFetchTime = Math.max(newLastFetchTime, node.getTimestamp());
@@ -80,12 +80,12 @@ public class StatisticNode implements Node {
}

@Override
public long blockedRequest() {
public long blockRequest() {
return rollingCounterInMinute.block() / 2;
}

@Override
public long blockedQps() {
public long blockQps() {
return rollingCounterInSecond.block() / IntervalProperty.INTERVAL;
}

@@ -101,7 +101,7 @@ public class StatisticNode implements Node {

@Override
public long totalQps() {
return passQps() + blockedQps();
return passQps() + blockQps();
}

@Override
@@ -170,7 +170,7 @@ public class StatisticNode implements Node {
}

@Override
public void increaseBlockedQps() {
public void increaseBlockQps() {
rollingCounterInSecond.addBlock();
rollingCounterInMinute.addBlock();
}


+ 32
- 32
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricNode.java View File

@@ -22,10 +22,10 @@ import java.util.Date;
public class MetricNode {

private long timestamp;
private long passedQps;
private long blockedQps;
private long passQps;
private long blockQps;
private long successQps;
private long exception;
private long exceptionQps;
private long rt;

private String resource;
@@ -46,28 +46,28 @@ public class MetricNode {
this.successQps = successQps;
}

public long getPassedQps() {
return passedQps;
public long getPassQps() {
return passQps;
}

public void setPassedQps(long passedQps) {
this.passedQps = passedQps;
public void setPassQps(long passQps) {
this.passQps = passQps;
}

public long getException() {
return exception;
public long getExceptionQps() {
return exceptionQps;
}

public void setException(long exception) {
this.exception = exception;
public void setExceptionQps(long exceptionQps) {
this.exceptionQps = exceptionQps;
}

public long getBlockedQps() {
return blockedQps;
public long getBlockQps() {
return blockQps;
}

public void setBlockedQps(long blockedQps) {
this.blockedQps = blockedQps;
public void setBlockQps(long blockQps) {
this.blockQps = blockQps;
}

public long getRt() {
@@ -90,10 +90,10 @@ public class MetricNode {
public String toString() {
return "MetricNode{" +
"timestamp=" + timestamp +
", passedQps=" + passedQps +
", blockedQs=" + blockedQps +
", passQps=" + passQps +
", blockQps=" + blockQps +
", successQps=" + successQps +
", exception=" + exception +
", exceptionQps=" + exceptionQps +
", rt=" + rt +
", resource='" + resource + '\'' +
'}';
@@ -103,7 +103,7 @@ public class MetricNode {
* To formatting string. All "|" in {@link #resource} will be replaced with "_", format is:
* <br/>
* <code>
* timestamp|resource|passedQps|blockedQps|successQps|exception|rt
* timestamp|resource|passQps|blockQps|successQps|exceptionQps|rt
* </code>
*
* @return string format of this.
@@ -113,10 +113,10 @@ public class MetricNode {
sb.append(timestamp).append("|");
String legalName = resource.replaceAll("\\|", "_");
sb.append(legalName).append("|");
sb.append(passedQps).append("|");
sb.append(blockedQps).append("|");
sb.append(passQps).append("|");
sb.append(blockQps).append("|");
sb.append(successQps).append("|");
sb.append(exception).append("|");
sb.append(exceptionQps).append("|");
sb.append(rt);
return sb.toString();
}
@@ -132,10 +132,10 @@ public class MetricNode {
String[] strs = line.split("\\|");
node.setTimestamp(Long.parseLong(strs[0]));
node.setResource(strs[1]);
node.setPassedQps(Long.parseLong(strs[2]));
node.setBlockedQps(Long.parseLong(strs[3]));
node.setPassQps(Long.parseLong(strs[2]));
node.setBlockQps(Long.parseLong(strs[3]));
node.setSuccessQps(Long.parseLong(strs[4]));
node.setException(Long.parseLong(strs[5]));
node.setExceptionQps(Long.parseLong(strs[5]));
node.setRt(Long.parseLong(strs[6]));
return node;
}
@@ -144,7 +144,7 @@ public class MetricNode {
* To formatting string. All "|" in {@link MetricNode#resource} will be replaced with "_", format is:
* <br/>
* <code>
* timestamp|yyyy-MM-dd HH:mm:ss|resource|passedQps|blockedQps|successQps|exception|rt\n
* timestamp|yyyy-MM-dd HH:mm:ss|resource|passQps|blockQps|successQps|exceptionQps|rt\n
* </code>
*
* @return string format of this.
@@ -157,10 +157,10 @@ public class MetricNode {
sb.append(df.format(new Date(getTimestamp()))).append("|");
String legalName = getResource().replaceAll("\\|", "_");
sb.append(legalName).append("|");
sb.append(getPassedQps()).append("|");
sb.append(getBlockedQps()).append("|");
sb.append(getPassQps()).append("|");
sb.append(getBlockQps()).append("|");
sb.append(getSuccessQps()).append("|");
sb.append(getException()).append("|");
sb.append(getExceptionQps()).append("|");
sb.append(getRt());
sb.append('\n');
return sb.toString();
@@ -178,10 +178,10 @@ public class MetricNode {
MetricNode node = new MetricNode();
node.setTimestamp(time);
node.setResource(strs[2]);
node.setPassedQps(Long.parseLong(strs[3]));
node.setBlockedQps(Long.parseLong(strs[4]));
node.setPassQps(Long.parseLong(strs[3]));
node.setBlockQps(Long.parseLong(strs[4]));
node.setSuccessQps(Long.parseLong(strs[5]));
node.setException(Long.parseLong(strs[6]));
node.setExceptionQps(Long.parseLong(strs[6]));
node.setRt(Long.parseLong(strs[7]));
return node;
}


+ 3
- 3
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/StatisticSlot.java View File

@@ -72,13 +72,13 @@ public class StatisticSlot extends AbstractLinkedProcessorSlot<DefaultNode> {
context.getCurEntry().setError(e);

// Add block count.
node.increaseBlockedQps();
node.increaseBlockQps();
if (context.getCurEntry().getOriginNode() != null) {
context.getCurEntry().getOriginNode().increaseBlockedQps();
context.getCurEntry().getOriginNode().increaseBlockQps();
}

if (resourceWrapper.getType() == EntryType.IN) {
Constants.ENTRY_NODE.increaseBlockedQps();
Constants.ENTRY_NODE.increaseBlockQps();
}

for (ProcessorSlotEntryCallback<DefaultNode> handler : StatisticSlotCallbackRegistry.getEntryCallbacks()) {


+ 3
- 3
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/metric/ArrayMetric.java View File

@@ -144,9 +144,9 @@ public class ArrayMetric implements Metric {
continue;
}
MetricNode node = new MetricNode();
node.setBlockedQps(window.value().block());
node.setException(window.value().exception());
node.setPassedQps(window.value().pass());
node.setBlockQps(window.value().block());
node.setExceptionQps(window.value().exception());
node.setPassQps(window.value().pass());
long passQps = window.value().success();
node.setSuccessQps(passQps);
if (passQps != 0) {


+ 28
- 31
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/MetricEntity.java View File

@@ -30,16 +30,13 @@ public class MetricEntity {
*/
private Date timestamp;
private String resource;
private Long passedQps;
private Long passQps;
private Long successQps;
private Long blockedQps;
/**
* 发生异常的次数
*/
private Long exception;
private Long blockQps;
private Long exceptionQps;

/**
* 所有successQps的Rt的和。
* summary rt of all success exit qps.
*/
private double rt;

@@ -58,26 +55,26 @@ public class MetricEntity {
entity.setApp(oldEntity.getApp());
entity.setTimestamp(oldEntity.getTimestamp());
entity.setResource(oldEntity.getResource());
entity.setPassedQps(oldEntity.getPassedQps());
entity.setBlockedQps(oldEntity.getBlockedQps());
entity.setPassQps(oldEntity.getPassQps());
entity.setBlockQps(oldEntity.getBlockQps());
entity.setSuccessQps(oldEntity.getSuccessQps());
entity.setException(oldEntity.getException());
entity.setExceptionQps(oldEntity.getExceptionQps());
entity.setRt(oldEntity.getRt());
entity.setCount(oldEntity.getCount());
entity.setResource(oldEntity.getResource());
return entity;
}

public synchronized void addPassedQps(Long passedQps) {
this.passedQps += passedQps;
public synchronized void addPassQps(Long passQps) {
this.passQps += passQps;
}

public synchronized void addBlockedQps(Long blockedQps) {
this.blockedQps += blockedQps;
public synchronized void addBlockQps(Long blockQps) {
this.blockQps += blockQps;
}

public synchronized void addException(Long exception) {
this.exception += exception;
public synchronized void addExceptionQps(Long exceptionQps) {
this.exceptionQps += exceptionQps;
}

public synchronized void addCount(int count) {
@@ -149,28 +146,28 @@ public class MetricEntity {
this.resourceCode = resource.hashCode();
}

public Long getPassedQps() {
return passedQps;
public Long getPassQps() {
return passQps;
}

public void setPassedQps(Long passedQps) {
this.passedQps = passedQps;
public void setPassQps(Long passQps) {
this.passQps = passQps;
}

public Long getBlockedQps() {
return blockedQps;
public Long getBlockQps() {
return blockQps;
}

public void setBlockedQps(Long blockedQps) {
this.blockedQps = blockedQps;
public void setBlockQps(Long blockQps) {
this.blockQps = blockQps;
}

public Long getException() {
return exception;
public Long getExceptionQps() {
return exceptionQps;
}

public void setException(Long exception) {
this.exception = exception;
public void setExceptionQps(Long exceptionQps) {
this.exceptionQps = exceptionQps;
}

public double getRt() {
@@ -210,10 +207,10 @@ public class MetricEntity {
", app='" + app + '\'' +
", timestamp=" + timestamp +
", resource='" + resource + '\'' +
", passedQps=" + passedQps +
", blockedQps=" + blockedQps +
", passQps=" + passQps +
", blockQps=" + blockQps +
", successQps=" + successQps +
", exception=" + exception +
", exceptionQps=" + exceptionQps +
", rt=" + rt +
", count=" + count +
", resourceCode=" + resourceCode +


+ 18
- 18
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/domain/ResourceTreeNode.java View File

@@ -32,13 +32,13 @@ public class ResourceTreeNode {

private Integer threadNum;
private Long passQps;
private Long blockedQps;
private Long blockQps;
private Long totalQps;
private Long averageRt;
private Long successQps;
private Long exceptionQps;
private Long oneMinutePassed;
private Long oneMinuteBlocked;
private Long oneMinutePass;
private Long oneMinuteBlock;
private Long oneMinuteException;
private Long oneMinuteTotal;

@@ -74,13 +74,13 @@ public class ResourceTreeNode {
node.resource = vo.getResource();
node.threadNum = vo.getThreadNum();
node.passQps = vo.getPassQps();
node.blockedQps = vo.getBlockedQps();
node.blockQps = vo.getBlockQps();
node.totalQps = vo.getTotalQps();
node.averageRt = vo.getAverageRt();
node.successQps = vo.getSuccessQps();
node.exceptionQps = vo.getExceptionQps();
node.oneMinutePassed = vo.getOneMinutePassed();
node.oneMinuteBlocked = vo.getOneMinuteBlocked();
node.oneMinutePass = vo.getOneMinutePass();
node.oneMinuteBlock = vo.getOneMinuteBlock();
node.oneMinuteException = vo.getOneMinuteException();
node.oneMinuteTotal = vo.getOneMinuteTotal();
return node;
@@ -151,12 +151,12 @@ public class ResourceTreeNode {
this.passQps = passQps;
}

public Long getBlockedQps() {
return blockedQps;
public Long getBlockQps() {
return blockQps;
}

public void setBlockedQps(Long blockedQps) {
this.blockedQps = blockedQps;
public void setBlockQps(Long blockQps) {
this.blockQps = blockQps;
}

public Long getTotalQps() {
@@ -191,20 +191,20 @@ public class ResourceTreeNode {
this.exceptionQps = exceptionQps;
}

public Long getOneMinutePassed() {
return oneMinutePassed;
public Long getOneMinutePass() {
return oneMinutePass;
}

public void setOneMinutePassed(Long oneMinutePassed) {
this.oneMinutePassed = oneMinutePassed;
public void setOneMinutePass(Long oneMinutePass) {
this.oneMinutePass = oneMinutePass;
}

public Long getOneMinuteBlocked() {
return oneMinuteBlocked;
public Long getOneMinuteBlock() {
return oneMinuteBlock;
}

public void setOneMinuteBlocked(Long oneMinuteBlocked) {
this.oneMinuteBlocked = oneMinuteBlocked;
public void setOneMinuteBlock(Long oneMinuteBlock) {
this.oneMinuteBlock = oneMinuteBlock;
}

public Long getOneMinuteException() {


+ 6
- 6
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/metric/MetricFetcher.java View File

@@ -304,19 +304,19 @@ public class MetricFetcher {
String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp());
MetricEntity entity = map.get(key);
if (entity != null) {
entity.addPassedQps(node.getPassedQps());
entity.addBlockedQps(node.getBlockedQps());
entity.addPassQps(node.getPassQps());
entity.addBlockQps(node.getBlockQps());
entity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps());
entity.addException(node.getException());
entity.addExceptionQps(node.getExceptionQps());
entity.addCount(1);
} else {
entity = new MetricEntity();
entity.setApp(machine.getApp());
entity.setTimestamp(new Date(node.getTimestamp()));
entity.setPassedQps(node.getPassedQps());
entity.setBlockedQps(node.getBlockedQps());
entity.setPassQps(node.getPassQps());
entity.setBlockQps(node.getBlockQps());
entity.setRtAndSuccessQps(node.getRt(), node.getSuccessQps());
entity.setException(node.getException());
entity.setExceptionQps(node.getExceptionQps());
entity.setCount(1);
entity.setResource(node.getResource());
map.put(key, entity);


+ 5
- 5
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java View File

@@ -113,10 +113,10 @@ public class InMemoryMetricsRepository implements MetricsRepository<MetricEntity
MetricEntity newEntity = metrics.getValue();
if (resourceCount.containsKey(resourceMetrics.getKey())) {
MetricEntity oldEntity = resourceCount.get(resourceMetrics.getKey());
oldEntity.addPassedQps(newEntity.getPassedQps());
oldEntity.addPassQps(newEntity.getPassQps());
oldEntity.addRtAndSuccessQps(newEntity.getRt(), newEntity.getSuccessQps());
oldEntity.addBlockedQps(newEntity.getBlockedQps());
oldEntity.addException(newEntity.getException());
oldEntity.addBlockQps(newEntity.getBlockQps());
oldEntity.addExceptionQps(newEntity.getExceptionQps());
oldEntity.addCount(1);
} else {
resourceCount.put(resourceMetrics.getKey(), MetricEntity.copyOf(newEntity));
@@ -129,11 +129,11 @@ public class InMemoryMetricsRepository implements MetricsRepository<MetricEntity
.sorted((o1, o2) -> {
MetricEntity e1 = o1.getValue();
MetricEntity e2 = o2.getValue();
int t = e2.getBlockedQps().compareTo(e1.getBlockedQps());
int t = e2.getBlockQps().compareTo(e1.getBlockQps());
if (t != 0) {
return t;
}
return e2.getPassedQps().compareTo(e1.getPassedQps());
return e2.getPassQps().compareTo(e1.getPassQps());
})
.map(Entry::getKey)
.collect(Collectors.toList());


+ 30
- 30
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/MetricVo.java View File

@@ -29,11 +29,11 @@ public class MetricVo implements Comparable<MetricVo> {
private String app;
private Long timestamp;
private Long gmtCreate = System.currentTimeMillis();
private String identity;
private Long passedQps;
private Long blockedQps;
private String resource;
private Long passQps;
private Long blockQps;
private Long successQps;
private Long exception;
private Long exceptionQps;
/**
* average rt
*/
@@ -78,11 +78,11 @@ public class MetricVo implements Comparable<MetricVo> {
vo.app = entity.getApp();
vo.timestamp = entity.getTimestamp().getTime();
vo.gmtCreate = entity.getGmtCreate().getTime();
vo.identity = entity.getResource();
vo.passedQps = entity.getPassedQps();
vo.blockedQps = entity.getBlockedQps();
vo.resource = entity.getResource();
vo.passQps = entity.getPassQps();
vo.blockQps = entity.getBlockQps();
vo.successQps = entity.getSuccessQps();
vo.exception = entity.getException();
vo.exceptionQps = entity.getExceptionQps();
if (entity.getSuccessQps() != 0) {
vo.rt = entity.getRt() / entity.getSuccessQps();
} else {
@@ -96,18 +96,18 @@ public class MetricVo implements Comparable<MetricVo> {
String[] strs = line.split("\\|");
long timestamp = Long.parseLong(strs[0]);
String identity = strs[1];
long passedQps = Long.parseLong(strs[2]);
long blockedQps = Long.parseLong(strs[3]);
long passQps = Long.parseLong(strs[2]);
long blockQps = Long.parseLong(strs[3]);
long exception = Long.parseLong(strs[4]);
double rt = Double.parseDouble(strs[5]);
long successQps = Long.parseLong(strs[6]);
MetricVo vo = new MetricVo();
vo.timestamp = timestamp;
vo.identity = identity;
vo.passedQps = passedQps;
vo.blockedQps = blockedQps;
vo.resource = identity;
vo.passQps = passQps;
vo.blockQps = blockQps;
vo.successQps = successQps;
vo.exception = exception;
vo.exceptionQps = exception;
vo.rt = rt;
vo.count = 1;
return vo;
@@ -145,28 +145,28 @@ public class MetricVo implements Comparable<MetricVo> {
this.gmtCreate = gmtCreate;
}

public String getIdentity() {
return identity;
public String getResource() {
return resource;
}

public void setIdentity(String identity) {
this.identity = identity;
public void setResource(String resource) {
this.resource = resource;
}

public Long getPassedQps() {
return passedQps;
public Long getPassQps() {
return passQps;
}

public void setPassedQps(Long passedQps) {
this.passedQps = passedQps;
public void setPassQps(Long passQps) {
this.passQps = passQps;
}

public Long getBlockedQps() {
return blockedQps;
public Long getBlockQps() {
return blockQps;
}

public void setBlockedQps(Long blockedQps) {
this.blockedQps = blockedQps;
public void setBlockQps(Long blockQps) {
this.blockQps = blockQps;
}

public Long getSuccessQps() {
@@ -177,12 +177,12 @@ public class MetricVo implements Comparable<MetricVo> {
this.successQps = successQps;
}

public Long getException() {
return exception;
public Long getExceptionQps() {
return exceptionQps;
}

public void setException(Long exception) {
this.exception = exception;
public void setExceptionQps(Long exceptionQps) {
this.exceptionQps = exceptionQps;
}

public Double getRt() {


+ 21
- 21
sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/ResourceVo.java View File

@@ -32,13 +32,13 @@ public class ResourceVo {

private Integer threadNum;
private Long passQps;
private Long blockedQps;
private Long blockQps;
private Long totalQps;
private Long averageRt;
private Long passRequestQps;
private Long exceptionQps;
private Long oneMinutePassed;
private Long oneMinuteBlocked;
private Long oneMinutePass;
private Long oneMinuteBlock;
private Long oneMinuteException;
private Long oneMinuteTotal;

@@ -64,12 +64,12 @@ public class ResourceVo {
vo.resource = nodeVo.getResource();
vo.threadNum = nodeVo.getThreadNum();
vo.passQps = nodeVo.getPassQps();
vo.blockedQps = nodeVo.getBlockedQps();
vo.blockQps = nodeVo.getBlockQps();
vo.totalQps = nodeVo.getTotalQps();
vo.averageRt = nodeVo.getAverageRt();
vo.exceptionQps = nodeVo.getExceptionQps();
vo.oneMinutePassed = nodeVo.getOneMinutePassed();
vo.oneMinuteBlocked = nodeVo.getOneMinuteBlocked();
vo.oneMinutePass = nodeVo.getOneMinutePass();
vo.oneMinuteBlock = nodeVo.getOneMinuteBlock();
vo.oneMinuteException = nodeVo.getOneMinuteException();
vo.oneMinuteTotal = nodeVo.getOneMinuteTotal();
list.add(vo);
@@ -103,12 +103,12 @@ public class ResourceVo {
vo.resource = node.getResource();
vo.threadNum = node.getThreadNum();
vo.passQps = node.getPassQps();
vo.blockedQps = node.getBlockedQps();
vo.blockQps = node.getBlockQps();
vo.totalQps = node.getTotalQps();
vo.averageRt = node.getAverageRt();
vo.exceptionQps = node.getExceptionQps();
vo.oneMinutePassed = node.getOneMinutePassed();
vo.oneMinuteBlocked = node.getOneMinuteBlocked();
vo.oneMinutePass = node.getOneMinutePass();
vo.oneMinuteBlock = node.getOneMinuteBlock();
vo.oneMinuteException = node.getOneMinuteException();
vo.oneMinuteTotal = node.getOneMinuteTotal();
vo.visible = node.isVisible();
@@ -159,12 +159,12 @@ public class ResourceVo {
this.passQps = passQps;
}

public Long getBlockedQps() {
return blockedQps;
public Long getBlockQps() {
return blockQps;
}

public void setBlockedQps(Long blockedQps) {
this.blockedQps = blockedQps;
public void setBlockQps(Long blockQps) {
this.blockQps = blockQps;
}

public Long getTotalQps() {
@@ -207,20 +207,20 @@ public class ResourceVo {
this.oneMinuteException = oneMinuteException;
}

public Long getOneMinutePassed() {
return oneMinutePassed;
public Long getOneMinutePass() {
return oneMinutePass;
}

public void setOneMinutePassed(Long oneMinutePassed) {
this.oneMinutePassed = oneMinutePassed;
public void setOneMinutePass(Long oneMinutePass) {
this.oneMinutePass = oneMinutePass;
}

public Long getOneMinuteBlocked() {
return oneMinuteBlocked;
public Long getOneMinuteBlock() {
return oneMinuteBlock;
}

public void setOneMinuteBlocked(Long oneMinuteBlocked) {
this.oneMinuteBlocked = oneMinuteBlocked;
public void setOneMinuteBlock(Long oneMinuteBlock) {
this.oneMinuteBlock = oneMinuteBlock;
}

public Long getOneMinuteTotal() {


+ 11
- 11
sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js View File

@@ -75,13 +75,13 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
type: 'time',
mask: 'YYYY-MM-DD HH:mm:ss'
});
chart.scale('passedQps', {
chart.scale('passQps', {
min: 0,
fine: true,
alias: 'p_qps'
// max: 10
});
chart.scale('blockedQps', {
chart.scale('blockQps', {
min: 0,
fine: true,
alias: 'b_qps',
@@ -94,7 +94,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
grid: null,
label: null
});
chart.axis('blockedQps', {
chart.axis('blockQps', {
grid: null,
label: null
});
@@ -118,17 +118,17 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
allowAllCanceled: true,
itemFormatter: function (val) {
// console.log('val=', val);
if ('passedQps' === val) {
if ('passQps' === val) {
return 'p_qps';
}
if ('blockedQps' === val) {
if ('blockQps' === val) {
return 'b_qps';
}
return val;
},
items: [
{ value: 'passedQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } },
{ value: 'blockedQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } },
{ value: 'passQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } },
{ value: 'blockQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } },
// { value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} },
],
onClick: function (ev) {
@@ -148,8 +148,8 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
}
}
});
chart.line().position('timestamp*passedQps').size(1).color('green').shape('smooth');
chart.line().position('timestamp*blockedQps').size(1).color('blue').shape('smooth');
chart.line().position('timestamp*passQps').size(1).color('green').shape('smooth');
chart.line().position('timestamp*blockQps').size(1).color('blue').shape('smooth');
// chart.line().position('timestamp*rt').size(1).color('gray');
G2.track(false);
chart.render();
@@ -214,8 +214,8 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
for (var j = lastTime + 1; j < curTime; j++) {
filledData.push({
"timestamp": j * 1000,
"passedQps": 0,
"blockedQps": 0,
"passQps": 0,
"blockQps": 0,
"successQps": 0,
"exception": 0,
"rt": 0,


+ 4
- 4
sentinel-dashboard/src/main/webapp/resources/app/views/identity.html View File

@@ -61,13 +61,13 @@
<!--</a>-->
</td>
<td>{{resource.passQps}}</td>
<td>{{resource.blockedQps}}</td>
<td>{{resource.blockQps}}</td>
<td>{{resource.threadNum}}</td>
<td>{{resource.averageRt}}</td>
<td>{{resource.oneMinutePassed}}</td>
<td>{{resource.oneMinutePass}}</td>
<td ng-if="$index==pageSize-1 || (currentPage>=identities.length/pageSize && $index==identities.length%pageSize-1)" ng-init="initTreeTable()">
{{resource.oneMinuteBlocked}}</td>
<td ng-if="!($index==pageSize-1 || (currentPage>=identities.length/pageSize && $index==identities.length%pageSize-1))"> {{resource.oneMinuteBlocked}}</td>
{{resource.oneMinuteBlock}}</td>
<td ng-if="!($index==pageSize-1 || (currentPage>=identities.length/pageSize && $index==identities.length%pageSize-1))"> {{resource.oneMinuteBlock}}</td>
<td>
<div class="control-group">
<button class="btn btn-xs btn-default" type="button" ng-click="addNewFlowRule(resource.resource)" style="font-size: 12px; height:25px;">


+ 2
- 2
sentinel-dashboard/src/main/webapp/resources/app/views/metric.html View File

@@ -60,8 +60,8 @@
<tbody>
<tr style="font-size: 12px;text-align:center;" ng-repeat="tableObj in metric.shortData">
<td style="word-wrap:break-word;word-break:break-all; ">{{tableObj.timestamp | date: 'HH:mm:ss'}}</td>
<td style="word-wrap:break-word;word-break:break-all; ">{{tableObj.passedQps | number : 1}}</td>
<td style="word-wrap:break-word;word-break:break-all; ">{{tableObj.blockedQps | number : 1}}</td>
<td style="word-wrap:break-word;word-break:break-all; ">{{tableObj.passQps | number : 1}}</td>
<td style="word-wrap:break-word;word-break:break-all; ">{{tableObj.blockQps | number : 1}}</td>
<td style="word-wrap:break-word;word-break:break-all;">{{tableObj.rt | number : 1}}</td>
</tr>
<tr style="font-size: 12px;text-align:center;" ng-repeat="_tr in [] | range : (6 - metric.shortData.length)">


+ 2
- 2
sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchClusterNodeHumanCommandHandler.java View File

@@ -71,8 +71,8 @@ public class FetchClusterNodeHumanCommandHandler implements CommandHandler<Strin
int lenNum = (int)Math.ceil((double)id.length() / nameLength) - 1;

sb.append(String.format(format, i + 1, lenNum == 0 ? id : id.substring(0, nameLength),
node.curThreadNum(), node.passQps(), node.blockedQps(), node.successQps(), node.totalQps(),
node.avgRt(), node.totalRequest() - node.blockedRequest(), node.blockedRequest(),
node.curThreadNum(), node.passQps(), node.blockQps(), node.successQps(), node.totalQps(),
node.avgRt(), node.totalRequest() - node.blockRequest(), node.blockRequest(),
node.totalRequest(), node.exceptionQps())).append("\n");
for (int j = 1; j <= lenNum; ++j) {
int start = nameLength * j;


+ 4
- 4
sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchOriginCommandHandler.java View File

@@ -82,8 +82,8 @@ public class FetchOriginCommandHandler implements CommandHandler<String> {
String format = FORMAT.replaceAll("80", String.valueOf(nameLength + 1));
i = 0;
sb.append(String
.format(format, "idx", "origin", "threadNum", "passedQps", "blockedQps", "totalQps", "aRt", "1m-passed",
"1m-blocked", "1m-total")).append("\n");
.format(format, "idx", "origin", "threadNum", "passQps", "blockQps", "totalQps", "aRt", "1m-pass",
"1m-block", "1m-total")).append("\n");

for (Entry<String, StatisticNode> e : cNode.getOriginCountMap().entrySet()) {
StatisticNode node = e.getValue();
@@ -91,8 +91,8 @@ public class FetchOriginCommandHandler implements CommandHandler<String> {
int lenNum = (int)Math.ceil((double)id.length() / nameLength) - 1;
sb.append(String
.format(format, i + 1, lenNum == 0 ? id : id.substring(0, nameLength), node.curThreadNum(),
node.passQps(), node.blockedQps(), node.totalQps(), node.avgRt(),
node.totalRequest() - node.blockedRequest(), node.blockedRequest(), node.totalRequest()))
node.passQps(), node.blockQps(), node.totalQps(), node.avgRt(),
node.totalRequest() - node.blockRequest(), node.blockRequest(), node.totalRequest()))
.append("\n");
for (int j = 1; j <= lenNum; ++j) {
int start = nameLength * j;


+ 1
- 1
sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchSystemStatusCommandHandler.java View File

@@ -38,7 +38,7 @@ public class FetchSystemStatusCommandHandler implements CommandHandler<String> {

systemStatus.put("rqps", Constants.ENTRY_NODE.successQps());
systemStatus.put("qps", Constants.ENTRY_NODE.passQps());
systemStatus.put("b", Constants.ENTRY_NODE.blockedQps());
systemStatus.put("b", Constants.ENTRY_NODE.blockQps());
systemStatus.put("r", Constants.ENTRY_NODE.avgRt());
systemStatus.put("t", Constants.ENTRY_NODE.curThreadNum());



+ 6
- 6
sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/handler/FetchTreeCommandHandler.java View File

@@ -62,8 +62,8 @@ public class FetchTreeCommandHandler implements CommandHandler<String> {
}
sb.append("\r\n\r\n");
sb.append(
"t:threadNum pq:passQps bq:blockedQps tq:totalQps rt:averageRt prq: passRequestQps 1mp:1m-passed "
+ "1mb:1m-blocked 1mt:1m-total").append("\r\n");
"t:threadNum pq:passQps bq:blockQps tq:totalQps rt:averageRt prq: passRequestQps 1mp:1m-pass "
+ "1mb:1m-block 1mt:1m-total").append("\r\n");
return CommandResponse.ofSuccess(sb.toString());
}

@@ -74,14 +74,14 @@ public class FetchTreeCommandHandler implements CommandHandler<String> {
if (!(node instanceof EntranceNode)) {
sb.append(String.format("%s(t:%s pq:%s bq:%s tq:%s rt:%s prq:%s 1mp:%s 1mb:%s 1mt:%s)",
node.getId().getShowName(), node.curThreadNum(), node.passQps(),
node.blockedQps(), node.totalQps(), node.avgRt(), node.successQps(),
node.totalRequest() - node.blockedRequest(), node.blockedRequest(),
node.blockQps(), node.totalQps(), node.avgRt(), node.successQps(),
node.totalRequest() - node.blockRequest(), node.blockRequest(),
node.totalRequest())).append("\n");
} else {
sb.append(String.format("EntranceNode: %s(t:%s pq:%s bq:%s tq:%s rt:%s prq:%s 1mp:%s 1mb:%s 1mt:%s)",
node.getId().getShowName(), node.curThreadNum(), node.passQps(),
node.blockedQps(), node.totalQps(), node.avgRt(), node.successQps(),
node.totalRequest() - node.blockedRequest(), node.blockedRequest(),
node.blockQps(), node.totalQps(), node.avgRt(), node.successQps(),
node.totalRequest() - node.blockRequest(), node.blockRequest(),
node.totalRequest())).append("\n");
}
for (Node n : node.getChildList()) {


+ 21
- 21
sentinel-transport/sentinel-transport-common/src/main/java/com/alibaba/csp/sentinel/command/vo/NodeVo.java View File

@@ -34,13 +34,13 @@ public class NodeVo {

private Integer threadNum;
private Long passQps;
private Long blockedQps;
private Long blockQps;
private Long totalQps;
private Long averageRt;
private Long successQps;
private Long exceptionQps;
private Long oneMinutePassed;
private Long oneMinuteBlocked;
private Long oneMinutePass;
private Long oneMinuteBlock;
private Long oneMinuteException;
private Long oneMinuteTotal;

@@ -64,14 +64,14 @@ public class NodeVo {
vo.resource = node.getId().getShowName();
vo.threadNum = node.curThreadNum();
vo.passQps = node.passQps();
vo.blockedQps = node.blockedQps();
vo.blockQps = node.blockQps();
vo.totalQps = node.totalQps();
vo.averageRt = node.avgRt();
vo.successQps = node.successQps();
vo.exceptionQps = node.exceptionQps();
vo.oneMinuteException = node.totalException();
vo.oneMinutePassed = node.totalRequest() - node.blockedRequest();
vo.oneMinuteBlocked = node.blockedRequest();
vo.oneMinutePass = node.totalRequest() - node.blockRequest();
vo.oneMinuteBlock = node.blockRequest();
vo.oneMinuteTotal = node.totalRequest();
vo.timestamp = System.currentTimeMillis();
return vo;
@@ -103,14 +103,14 @@ public class NodeVo {
vo.resource = name;
vo.threadNum = node.curThreadNum();
vo.passQps = node.passQps();
vo.blockedQps = node.blockedQps();
vo.blockQps = node.blockQps();
vo.totalQps = node.totalQps();
vo.averageRt = node.avgRt();
vo.successQps = node.successQps();
vo.exceptionQps = node.exceptionQps();
vo.oneMinuteException = node.totalException();
vo.oneMinutePassed = node.totalRequest() - node.blockedRequest();
vo.oneMinuteBlocked = node.blockedRequest();
vo.oneMinutePass = node.totalRequest() - node.blockRequest();
vo.oneMinuteBlock = node.blockRequest();
vo.oneMinuteTotal = node.totalRequest();
vo.timestamp = System.currentTimeMillis();
return vo;
@@ -156,12 +156,12 @@ public class NodeVo {
this.passQps = passQps;
}

public Long getBlockedQps() {
return blockedQps;
public Long getBlockQps() {
return blockQps;
}

public void setBlockedQps(Long blockedQps) {
this.blockedQps = blockedQps;
public void setBlockQps(Long blockQps) {
this.blockQps = blockQps;
}

public Long getTotalQps() {
@@ -204,20 +204,20 @@ public class NodeVo {
this.oneMinuteException = oneMinuteException;
}

public Long getOneMinutePassed() {
return oneMinutePassed;
public Long getOneMinutePass() {
return oneMinutePass;
}

public void setOneMinutePassed(Long oneMinutePassed) {
this.oneMinutePassed = oneMinutePassed;
public void setOneMinutePass(Long oneMinutePass) {
this.oneMinutePass = oneMinutePass;
}

public Long getOneMinuteBlocked() {
return oneMinuteBlocked;
public Long getOneMinuteBlock() {
return oneMinuteBlock;
}

public void setOneMinuteBlocked(Long oneMinuteBlocked) {
this.oneMinuteBlocked = oneMinuteBlocked;
public void setOneMinuteBlock(Long oneMinuteBlock) {
this.oneMinuteBlock = oneMinuteBlock;
}

public Long getOneMinuteTotal() {


Loading…
Cancel
Save