Commit ca53eff4 by amir

2.0.4 add hystrix metrics to display

parent 6cef7404
group 'com.ipgallery.common' group 'com.ipgallery.common'
version '2.0.2-services' version '2.0.4-services'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
......
...@@ -7,6 +7,7 @@ import java.util.stream.Collectors; ...@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.codahale.metrics.Counter; import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter; import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer; import com.codahale.metrics.Timer;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -70,6 +71,7 @@ public class MonitorHandler implements CommonServices.IMethodClass ...@@ -70,6 +71,7 @@ public class MonitorHandler implements CommonServices.IMethodClass
final SortedMap<String, Counter> counterSortedMap = factoryImpl.getMetrics().getCounters(); final SortedMap<String, Counter> counterSortedMap = factoryImpl.getMetrics().getCounters();
final SortedMap<String, Meter> meterSortedMap = factoryImpl.getMetrics().getMeters(); final SortedMap<String, Meter> meterSortedMap = factoryImpl.getMetrics().getMeters();
final SortedMap<String, Timer> timerSortedMap = factoryImpl.getMetrics().getTimers(); final SortedMap<String, Timer> timerSortedMap = factoryImpl.getMetrics().getTimers();
final SortedMap<String, Gauge> gaugeSortedMap = factoryImpl.getMetrics().getGauges();
if ("list".equals(reqCtx.getParameter("viewType"))) if ("list".equals(reqCtx.getParameter("viewType")))
{ {
// as list // as list
...@@ -100,7 +102,15 @@ public class MonitorHandler implements CommonServices.IMethodClass ...@@ -100,7 +102,15 @@ public class MonitorHandler implements CommonServices.IMethodClass
}).collect(Collectors.toList()); }).collect(Collectors.toList());
objectNode.set("timers", this.objMapper.valueToTree(meters)); objectNode.set("timers", this.objMapper.valueToTree(meters));
} }
if (!gaugeSortedMap.isEmpty()) {
final List<ObjectNode> meters = gaugeSortedMap.entrySet().stream().map(metricEntry -> {
ObjectNode objNode = JsonNodeFactory.instance.objectNode().put(FIELD_NAME, metricEntry.getKey());
final JsonNode jsonNode = this.objMapper.valueToTree(metricEntry.getValue());
jsonNode.fields().forEachRemaining(entry -> objNode.set(entry.getKey(), entry.getValue()));
return objNode;
}).collect(Collectors.toList());
objectNode.set("gauges", this.objMapper.valueToTree(meters));
}
} else { } else {
// as object // as object
......
...@@ -6,6 +6,7 @@ import java.util.Optional; ...@@ -6,6 +6,7 @@ import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer; import java.util.function.Consumer;
import com.netflix.config.ConfigurationManager;
import microservice.MicroserviceApp; import microservice.MicroserviceApp;
import microservice.defs.Enums; import microservice.defs.Enums;
import microservice.io.iface.IServiceDiscovery; import microservice.io.iface.IServiceDiscovery;
......
...@@ -7,21 +7,28 @@ ...@@ -7,21 +7,28 @@
<script> <script>
// Builds the HTML Table out of myList. // Builds the HTML Table out of myList.
function buildHtmlTable(data) { function buildHtmlTable(data) {
// meters
var selector = '#meterTable'; var selector = '#meterTable';
$(selector).empty() $(selector).empty()
var list = data.objectNode.meters; var list = data.objectNode.meters;
var columns = addAllColumnHeaders(list, selector); var columns = addAllColumnHeaders(list, selector);
addRows(selector,columns,list); addRows(selector,columns,list);
// timers
selector = '#timerTable'; selector = '#timerTable';
$(selector).empty() $(selector).empty()
list = data.objectNode.timers; list = data.objectNode.timers;
columns = addAllColumnHeaders(list, selector);
addRows(selector,columns,list);
// gauges
selector = '#gaugeTable';
$(selector).empty()
list = data.objectNode.gauges;
columns = addAllColumnHeaders(list, selector); columns = addAllColumnHeaders(list, selector);
addRows(selector,columns,list); addRows(selector,columns,list);
} }
function addRows(selector,columns,myList){ function addRows(selector,columns,myList){
...@@ -87,6 +94,8 @@ $(document).ready(function(){ ...@@ -87,6 +94,8 @@ $(document).ready(function(){
</table> </table>
<table class="striped" id="timerTable" border="1"> <table class="striped" id="timerTable" border="1">
</table> </table>
<table class="striped" id="gaugeTable" border="1">
</table>
</body> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment