monitor.ftl 7.56 KB
Newer Older
1
<#import "/spring.ftl" as spring />
Dave Syer committed
2 3 4
<!doctype html>
<html lang="en">
<head>
5
    <base href="${basePath}">
Dave Syer committed
6 7 8 9 10
	<meta charset="utf-8" />
	<title>Hystrix Monitor</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

	<!-- Setup base for everything -->
11
	<link rel="stylesheet" type="text/css" href="css/global.css" />
Dave Syer committed
12 13
	
	<!-- Our custom CSS -->
14
	<link rel="stylesheet" type="text/css" href="css/monitor.css" />
Dave Syer committed
15 16

	<!-- d3 -->
17
    <script type="text/javascript" src="<@spring.url '/webjars/d3js/3.4.11/d3.min.js'/>" ></script>
Dave Syer committed
18 19
	
	<!-- Javascript to monitor and display -->
20
    <script type="text/javascript" src="<@spring.url '/webjars/jquery/2.1.1/jquery.min.js'/>" ></script>
21 22
	<script type="text/javascript" src="js/jquery.tinysort.min.js"></script>
	<script type="text/javascript" src="js/tmpl.js"></script>
Dave Syer committed
23 24
	
	<!-- HystrixCommand -->
25 26
	<script type="text/javascript" src="components/hystrixCommand/hystrixCommand.js"></script>
	<link rel="stylesheet" type="text/css" href="components/hystrixCommand/hystrixCommand.css" />
Dave Syer committed
27 28
	
	<!-- HystrixThreadPool -->
29 30
	<script type="text/javascript" src="components/hystrixThreadPool/hystrixThreadPool.js"></script>
	<link rel="stylesheet" type="text/css" href="components/hystrixThreadPool/hystrixThreadPool.css" />
Dave Syer committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

</head>
<body>
	<div id="header">
		<h2><span id="title_name"></span></h2>
	</div>

	<div class="container">
		<div class="row">
			<div class="menubar">
				<div class="title">
				Circuit
				</div>
				<div class="menu_actions">
					Sort: 
					<a href="javascript://" onclick="hystrixMonitor.sortByErrorThenVolume();">Error then Volume</a> |
					<a href="javascript://" onclick="hystrixMonitor.sortAlphabetically();">Alphabetical</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByVolume();">Volume</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByError();">Error</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByLatencyMean();">Mean</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByLatencyMedian();">Median</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByLatency90();">90</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByLatency99();">99</a> | 
					<a href="javascript://" onclick="hystrixMonitor.sortByLatency995();">99.5</a> 
				</div>
				<div class="menu_legend">
57
					<span class="success">Success</span> | <span class="shortCircuited">Short-Circuited</span> | <span class="badRequest"> Bad Request</span> | <span class="timeout">Timeout</span> | <span class="rejected">Rejected</span> | <span class="failure">Failure</span> | <span class="errorPercentage">Error %</span>
Dave Syer committed
58 59 60 61 62 63
				</div>
			</div>
		</div>
		<div id="dependencies" class="row dependencies"><span class="loading">Loading ...</span></div>
		
		<div class="spacer"></div>
64

Dave Syer committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
		<div class="row">
			<div class="menubar">
				<div class="title">
				Thread Pools
				</div>
				<div class="menu_actions">
					Sort: <a href="javascript://" onclick="dependencyThreadPoolMonitor.sortAlphabetically();">Alphabetical</a> | 
					<a href="javascript://" onclick="dependencyThreadPoolMonitor.sortByVolume();">Volume</a> | 
				</div>
			</div>
		</div>
		<div id="dependencyThreadPools" class="row dependencyThreadPools"><span class="loading">Loading ...</span></div>
	</div>



<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 stream = getUrlVars()["stream"];
		
		console.log("Stream: " + stream)
		
		if(stream != undefined) {
			if(getUrlVars()["delay"] != undefined) {
				stream = stream + "&delay=" + getUrlVars()["delay"];
			}
			
100 101
			var commandStream = "${contextPath}/proxy.stream?origin=" + stream;
			var poolStream = "${contextPath}/proxy.stream?origin=" + stream;
Dave Syer committed
102 103
			
			if(getUrlVars()["title"] != undefined) {
104
				$('#title_name').text("Hystrix Stream: " + decodeURIComponent(getUrlVars()["title"]))
Dave Syer committed
105
			} else {
106
				$('#title_name').text("Hystrix Stream: " + decodeURIComponent(stream))
Dave Syer committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
			}
		}
		console.log("Command Stream: " + commandStream)
				
		$(window).load(function() { // within load with a setTimeout to prevent the infinite spinner
			setTimeout(function() {
				if(commandStream == undefined) {
						console.log("commandStream is undefined")
						$("#dependencies .loading").html("The 'stream' argument was not provided.");
						$("#dependencies .loading").addClass("failed");
				} else {
					// sort by error+volume by default
					hystrixMonitor.sortByErrorThenVolume();
					
					// start the EventSource which will open a streaming connection to the server
					var source = new EventSource(commandStream);
					
					// add the listener that will process incoming events
					source.addEventListener('message', hystrixMonitor.eventSourceMessageListener, false);

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

					source.addEventListener('error', function(e) {
133 134
						$("#dependencies .loading").html("Unable to connect to Command Metric Stream.");
						$("#dependencies .loading").addClass("failed");
Dave Syer committed
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
					  if (e.eventPhase == EventSource.CLOSED) {
					    // Connection was closed.
						  console.log("Connection was closed on error: " + JSON.stringify(e));
					  } else {
						  console.log("Error occurred while streaming: " + JSON.stringify(e));
					  }
					}, false);
				}
			},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) {
170 171
                        $("#dependencies .loading").html("Unable to connect to Command Metric Stream.");
                        $("#dependencies .loading").addClass("failed");
Dave Syer committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
					  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;
		}
		
	</script>


</body>
</html>