Commit f5a2b8ee by amir

2.0.4 add hystrix metrics to display

parent 492b0a5c
group 'com.ipgallery.common'
version '2.0.2-services'
version '2.0.4-services'
apply plugin: 'java'
apply plugin: 'maven-publish'
......
......@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -70,6 +71,7 @@ public class MonitorHandler implements CommonServices.IMethodClass
final SortedMap<String, Counter> counterSortedMap = factoryImpl.getMetrics().getCounters();
final SortedMap<String, Meter> meterSortedMap = factoryImpl.getMetrics().getMeters();
final SortedMap<String, Timer> timerSortedMap = factoryImpl.getMetrics().getTimers();
final SortedMap<String, Gauge> gaugeSortedMap = factoryImpl.getMetrics().getGauges();
if ("list".equals(reqCtx.getParameter("viewType")))
{
// as list
......@@ -100,7 +102,15 @@ public class MonitorHandler implements CommonServices.IMethodClass
}).collect(Collectors.toList());
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 {
// as object
......
......@@ -6,6 +6,7 @@ import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer;
import com.netflix.config.ConfigurationManager;
import microservice.MicroserviceApp;
import microservice.defs.Enums;
import microservice.io.iface.IServiceDiscovery;
......
......@@ -7,21 +7,28 @@
<script>
// Builds the HTML Table out of myList.
function buildHtmlTable(data) {
// meters
var selector = '#meterTable';
$(selector).empty()
var list = data.objectNode.meters;
var columns = addAllColumnHeaders(list, selector);
addRows(selector,columns,list);
// timers
selector = '#timerTable';
$(selector).empty()
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);
addRows(selector,columns,list);
}
function addRows(selector,columns,myList){
......@@ -87,6 +94,8 @@ $(document).ready(function(){
</table>
<table class="striped" id="timerTable" border="1">
</table>
<table class="striped" id="gaugeTable" border="1">
</table>
</body>
</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