You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/08/10 07:50:15 UTC
[servicecomb-pack] 10/36: SCB-1411 Implement dashboard slow
transaction top N
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git
commit c0b2b7b5b5cf53ba061f5d6792f10d5de3bd9431
Author: Lei Zhang <co...@gmail.com>
AuthorDate: Wed Aug 7 23:39:28 2019 +0800
SCB-1411 Implement dashboard slow transaction top N
---
.../pack/alpha/ui/TransactionController.java | 29 ++++++++++++++++++++++
.../main/resources/static/js/alpha-dashboard.js | 20 +++++++++++++++
.../src/main/resources/templates/index.html | 2 +-
3 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/alpha/alpha-ui/src/main/java/org/apache/servicecomb/pack/alpha/ui/TransactionController.java b/alpha/alpha-ui/src/main/java/org/apache/servicecomb/pack/alpha/ui/TransactionController.java
index ff47ec7..bbadf70 100644
--- a/alpha/alpha-ui/src/main/java/org/apache/servicecomb/pack/alpha/ui/TransactionController.java
+++ b/alpha/alpha-ui/src/main/java/org/apache/servicecomb/pack/alpha/ui/TransactionController.java
@@ -33,6 +33,8 @@ import org.apache.servicecomb.pack.alpha.ui.vo.TransactionStatisticsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@@ -196,6 +198,33 @@ public class TransactionController implements ApplicationListener<WebServerIniti
return statisticsDTO;
}
+ @GetMapping("/ui/transaction/slow")
+ @ResponseBody
+ public List<TransactionRowDTO> getSlowGlobalTransactionTopN() {
+ List<TransactionRowDTO> transactionRowDTOS = new ArrayList<>();
+ UriComponents uriComponents = UriComponentsBuilder
+ .fromUriString("http://localhost:" + serverPort + "/alpha/api/v1/transaction/slow")
+ .build();
+ ResponseEntity<List<GlobalTransaction>> entity = restTemplate
+ .exchange(uriComponents.toUriString(), HttpMethod.GET, null,
+ new ParameterizedTypeReference<List<GlobalTransaction>>() {
+ });
+ List<GlobalTransaction> transactions = entity.getBody();
+ transactions.stream().forEach( globalTransaction -> {
+ transactionRowDTOS.add(TransactionRowDTO.builder()
+ .serviceName(globalTransaction.getServiceName())
+ .instanceId(globalTransaction.getInstanceId())
+ .globalTxId(globalTransaction.getGlobalTxId())
+ .state(globalTransaction.getState())
+ .beginTime(globalTransaction.getBeginTime())
+ .endTime(globalTransaction.getEndTime())
+ .subTxSize(globalTransaction.getSubTxSize())
+ .durationTime(globalTransaction.getDurationTime())
+ .build());
+ });
+ return transactionRowDTOS;
+ }
+
private GlobalTransaction findGlobalTransactionByGlobalTxId(String globalTxId){
UriComponents uriComponents = UriComponentsBuilder
.fromUriString("http://localhost:" + serverPort + "/alpha/api/v1/transaction/"+globalTxId)
diff --git a/alpha/alpha-ui/src/main/resources/static/js/alpha-dashboard.js b/alpha/alpha-ui/src/main/resources/static/js/alpha-dashboard.js
index e292e7a..d64d657 100644
--- a/alpha/alpha-ui/src/main/resources/static/js/alpha-dashboard.js
+++ b/alpha/alpha-ui/src/main/resources/static/js/alpha-dashboard.js
@@ -27,4 +27,24 @@ $(document).ready(function () {
// TODO show message
}
});
+
+ $.ajax('/ui/transaction/slow', {
+ success: function (data) {
+ for (i = 0; i < data.length; i++) {
+ $('.slow-topn').append(
+ '<a href="/ui/transaction/' + data[i].globalTxId
+ + '"><div class="progress mb-3" id="slow-top-"' + i + '>\n'
+ + '<div class="progress-bar" role="progressbar" style="cursor:pointer; width: '
+ + (data[i].durationTime / data[0].durationTime) * 100
+ + '%" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100">'
+ + data[i].durationTime + ' ms</div>\n'
+ + '</div></a>')
+ }
+ },
+ error: function (state) {
+ // TODO show message
+ }
+ });
+
+
});
\ No newline at end of file
diff --git a/alpha/alpha-ui/src/main/resources/templates/index.html b/alpha/alpha-ui/src/main/resources/templates/index.html
index bc13638..5ed8b7f 100644
--- a/alpha/alpha-ui/src/main/resources/templates/index.html
+++ b/alpha/alpha-ui/src/main/resources/templates/index.html
@@ -123,7 +123,7 @@
</div>
<!-- Card Body -->
<div class="card-body">
- <div class="chart-area">
+ <div class="slow-topn">
</div>
</div>
</div>