Skip to content

Commit

Permalink
Merging in latest changes to monitor.html to:
Browse files Browse the repository at this point in the history
  • Loading branch information
cgray committed Oct 6, 2015
1 parent f4612cb commit ad69e23
Showing 1 changed file with 31 additions and 68 deletions.
99 changes: 31 additions & 68 deletions breakerbox-dashboard/src/main/resources/assets/monitor/monitor.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<div id="dependencies" class="row dependencies"><span class="loading">Loading ...</span></div>

<div class="spacer"></div>

<div class="row">
<div class="menubar">
<div class="title">
Expand All @@ -73,53 +73,55 @@



<script>
<script>
/**
* Queue up the monitor to start once the page has finished loading.
*
* This is an inline script and expects to execute once on page load.
*/

// commands
var hystrixMonitor = new HystrixCommandMonitor('dependencies', {includeDetailIcon:false});

var dependencyThreadPoolMonitor = new HystrixThreadPoolMonitor('dependencyThreadPools');

var stream = getUrlVars()["stream"];

if(stream != undefined) {
if(getUrlVars()["delay"] != undefined) {
stream = stream + "&delay=" + getUrlVars()["delay"];
}

if(getUrlVars()["title"] != undefined) {
$('#title_name').html("Hystrix Stream: " + decodeURIComponent(getUrlVars()["title"]))
$('#title_name').text("Hystrix Stream: " + decodeURIComponent(getUrlVars()["title"]))
} else {
$('#title_name').html("Hystrix Stream: " + decodeURIComponent(stream))
$('#title_name').text("Hystrix Stream: " + decodeURIComponent(stream))
}

//do not show authorization in stream title
if(getUrlVars()["authorization"] != undefined) {
stream = stream + "&authorization=" + getUrlVars()["authorization"];
}
//do not show authorization in stream title
if(getUrlVars()["authorization"] != undefined) {
stream = stream + "&authorization=" + getUrlVars()["authorization"];
}

var commandStream = "/tenacity/proxy.stream?origin=" + stream;
var poolStream = "/tenacity/proxy.stream?origin=" + stream;
var proxyStream = "/tenacity/proxy.stream?origin=" + stream;
}

$(window).load(function() { // within load with a setTimeout to prevent the infinite spinner
setTimeout(function() {
if(commandStream == undefined) {
console.log("commandStream is undefined")
if(proxyStream == undefined) {
console.log("proxyStream is undefined")
$("#dependencies .loading").html("The 'stream' argument was not provided.");
$("#dependencies .loading").addClass("failed");
} else {
// sort by error+volume by default
hystrixMonitor.sortByErrorThenVolume();

dependencyThreadPoolMonitor.sortByVolume();

// start the EventSource which will open a streaming connection to the server
var source = new EventSource(commandStream);
var source = new EventSource(proxyStream);

// add the listener that will process incoming events
source.addEventListener('message', hystrixMonitor.eventSourceMessageListener, false);
source.addEventListener('message', dependencyThreadPoolMonitor.eventSourceMessageListener, false);

// source.addEventListener('open', function(e) {
// console.console.log(">>> opened connection, phase: " + e.eventPhase);
Expand All @@ -139,59 +141,20 @@
}
},0);
});

// thread pool
var dependencyThreadPoolMonitor = new HystrixThreadPoolMonitor('dependencyThreadPools');

$(window).load(function() { // within load with a setTimeout to prevent the infinite spinner
setTimeout(function() {
if(poolStream == undefined) {
console.log("poolStream is undefined")
$("#dependencyThreadPools .loading").html("The 'stream' argument was not provided.");
$("#dependencyThreadPools .loading").addClass("failed");
} else {
dependencyThreadPoolMonitor.sortByVolume();

// start the EventSource which will open a streaming connection to the server
var source = new EventSource(poolStream);

// add the listener that will process incoming events
source.addEventListener('message', dependencyThreadPoolMonitor.eventSourceMessageListener, false);

// source.addEventListener('open', function(e) {
// console.console.log(">>> opened connection, phase: " + e.eventPhase);
// // Connection was opened.
// }, false);

source.addEventListener('error', function(e) {
$("#dependencyThreadPools .loading").html("Unable to connect to Thread Pool Metric Stream.");
$("#dependencyThreadPools .loading").addClass("failed");
if (e.eventPhase == EventSource.CLOSED) {
// Connection was closed.
console.log("Connection was closed on error: " + e);
} else {
console.log("Error occurred while streaming: " + e);
}
}, false);
}
},0);
});

//Read a page's GET URL variables and return them as an associative array.
// from: http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}

</script>


Expand Down

0 comments on commit ad69e23

Please sign in to comment.