forked from linkedin/parseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace.html
More file actions
179 lines (155 loc) · 4.99 KB
/
trace.html
File metadata and controls
179 lines (155 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
57
58
59
60
61
62
63
64
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
100
101
102
103
104
105
106
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
133
134
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
170
171
172
173
174
175
176
177
178
179
<!--
* Copyright 2012 LinkedIn, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
-->
<!doctype html>
<meta charset="utf-8"/>
<title>ParSeq JSON Trace Viewer</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/table.css">
<link rel="stylesheet" href="css/waterfall.css">
<style>
.btnCenter {
margin: 0 50%;
}
textarea {
width: 760px;
}
textarea.error {
color: red;
}
</style>
<div class="container-fluid">
<div class="row-fluid">
<div class="page-header">
<h1>ParSeq JSON Trace Viewer</h1>
</div>
</div>
<div class="row-fluid">
<div class="page-header">
<h2>View Configuration</h2>
</div>
<form action="javascript:void(0);">
<fieldset>
<div class="span2">
<ul class="nav nav-list">
<li class="nav-header">Views</li>
<li id="viewWaterfall"><a onclick="setView('waterfall'); refreshView();">Waterfall</a></li>
<li id="viewGraphviz"><a onclick="setView('graphviz'); refreshView();">Graphviz</a></li>
<li id="viewTable"><a onclick="setView('table'); refreshView();">Table</a></li>
</ul>
</div>
<div class="span10">
<textarea id="jsonText" rows=3 placeholder="Insert JSON trace here" onkeyup="refreshView();"></textarea>
<label class="checkbox">
<input id="checkboxExcludeUser" type="checkbox" checked="checked" onclick="refreshView();">Don't show <em>user</em> hidden tasks
</label>
<label class="checkbox">
<input id="checkboxExcludeSystem" type="checkbox" checked="checked" onclick="refreshView();">Don't show <em>system</em> hidden tasks
</label>
<label class="checkbox">
<input id="checkboxExcludeParent" type="checkbox" onclick="refreshView();">Don't show parent tasks
</label>
</div>
</fieldset>
</form>
</div>
<div class="row-fluid">
<div class="page-header">
<h2>Trace View</h2>
</div>
</div>
<div id="resultView" class="row-fluid">
</div>
</div>
<script src="node_modules/d3/d3.js"></script>
<script src="build/parseq-tracevis.js"></script>
<script>
var
WATERFALL = parseqTracevis.renderWaterfall,
GRAPHVIZ = parseqTracevis.renderGraphviz,
TABLE = parseqTracevis.renderTable;
var inputJSON = d3.select("#jsonText");
var currentView;
setView("waterfall");
/* If the URL contains a trace, inject it into the input textarea */
var traceRE = /(?:\?|&)trace=([^\&]+)/;
var searchStr = window.location.search;
var match = traceRE.exec(searchStr);
if (match) {
renderTrace(decodeURIComponent(match[1]));
}
function setView(view) {
var prevView = selectView(currentView);
if (prevView) {
prevView.classed("active", false);
}
currentView = view;
selectView(view).classed("active", true);
}
function selectView(view) {
switch (view) {
case "waterfall": return d3.select("#viewWaterfall");
case "graphviz": return d3.select("#viewGraphviz");
case "table": return d3.select("#viewTable");
}
}
function refreshView() {
var view;
switch (currentView) {
case "waterfall": view = WATERFALL; break;
case "graphviz": view = GRAPHVIZ; break;
case "table": view = TABLE; break;
}
d3.selectAll("#resultView *").remove();
var jsonText = inputJSON.property("value");
if (!jsonText.length) {
return;
}
var json;
try {
json = JSON.parse(jsonText);
inputJSON.classed("error", false);
inputJSON.attr("title", null);
} catch (err) {
inputJSON.classed("error", true);
inputJSON.attr("title", "Parsing trace failed: " + err);
throw err;
}
var g = parseqTracevis.trace.parse(json);
if (d3.select("#checkboxExcludeUser").property("checked")) {
parseqTracevis.trace.excludeUserTasks(g);
}
if (d3.select("#checkboxExcludeSystem").property("checked")) {
parseqTracevis.trace.excludeSystemTasks(g);
}
if (d3.select("#checkboxExcludeParent").property("checked")) {
parseqTracevis.trace.excludeParentTasks(g);
}
view(d3.select("#resultView").attr('class', 'row-fluid'), g);
}
/**
* This is a utility that abstracts the details of how to programmatically load
* a trace and render it. If a view is not supplied then the current view is
* used. The default view is "waterfall".
*
* This function should be preferred to direct use of DOM ids / functions as
* they may change in the future.
*/
function renderTrace(trace, view) {
inputJSON.property("value", trace);
if (arguments.length > 1) setView(view);
refreshView();
}
</script>