Skip to content

Commit 5bd9d00

Browse files
Tracevis rewrite
- Simplified code - Better code coverage - Use NPM to pull in dependencies - Use jshint
1 parent ef8e14c commit 5bd9d00

36 files changed

+2200
-2589
lines changed

build.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,8 @@
104104
<make-jar destfile="${dist.dir}/${ant.project.name}-${version}-sources.jar" basedir="${src.dir}" />
105105
</target>
106106

107-
<target name="tar-tracevis" depends="prepare" description="Creates a tarball of the tracevis tool">
108-
<tar destfile="${dist.dir}/${ant.project.name}-tracevis-${version}.tar.gz" compression="gzip">
109-
<tarfileset dir="${tools.dir}/tracevis" prefix="tracevis">
110-
<include name="bootstrap/**"/>
111-
<include name="css/**"/>
112-
<include name="js/**"/>
113-
<include name="lib/**"/>
114-
<include name="trace.html"/>
115-
</tarfileset>
116-
</tar>
107+
<target name="tar-tracevis" depends="prepare, dist-tracevis" description="Creates a tarball of the tracevis tool">
108+
<copy file="${tools.dir}/tracevis/dist/parseq-tracevis.tar.gz" tofile="${dist.dir}/parseq-tracevis-${version}.tar.gz"/>
117109
</target>
118110

119111
<target name="doc" description="Build the javadoc." depends="build-src">
@@ -219,6 +211,14 @@
219211
</make>
220212
</target>
221213

214+
<target name="dist-tracevis" description="Builds the tracevis package">
215+
<make dir="${tools.dir}/tracevis">
216+
<args>
217+
<arg value="dist" />
218+
</args>
219+
</make>
220+
</target>
221+
222222
<macrodef name="sign">
223223
<attribute name="file"/>
224224
<sequential>

tools/tracevis/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
/dist
3+
/node_modules

tools/tracevis/.jshintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"eqeqeq": true,
3+
"newcap": true,
4+
"quotmark": true,
5+
"unused": true,
6+
"trailing": true,
7+
"laxbreak": true
8+
}

tools/tracevis/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
/node_modules

tools/tracevis/Makefile

Lines changed: 115 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,122 @@
1-
NODE?=node
2-
NPM?=npm
3-
MOCHA?=./node_modules/mocha/bin/mocha
4-
MOCHA_OPTS?=-R spec
1+
# Binaries we use
2+
NPM = npm
53

6-
ALL: test
4+
BROWSERIFY = ./node_modules/browserify/bin/cmd.js
5+
ISTANBUL = ./node_modules/istanbul/lib/cli.js
6+
JSHINT = ./node_modules/jshint/bin/jshint
7+
MOCHA = ./node_modules/mocha/bin/_mocha
8+
PHANTOMJS = ./node_modules/phantomjs/bin/phantomjs
9+
UGLIFY = ./node_modules/uglify-js/bin/uglifyjs
710

8-
node_modules:
9-
@npm install
11+
# Module def
12+
MODULE = parseq-tracevis
13+
MODULE_JS = $(MODULE).js
14+
MODULE_MIN_JS = $(MODULE).min.js
15+
MODULE_TAR_GZ = $(MODULE).tar.gz
1016

11-
test: node_modules
12-
$(MOCHA) $(MOCHA_OPTS) --recursive test
17+
# Various files
18+
SRC_FILES = $(wildcard lib/*.js lib/*/*.js lib/*/*/*.js)
19+
TEST_UNIT_FILES = $(wildcard test/unit/*.js test/unit/**/*.js)
20+
TEST_INT_FILES = $(wildcard test/int/*.js)
21+
TEST_FILES = $(TEST_UNIT_FILES) $(TEST_INT_FILES)
22+
23+
TEST_UNIT_COV = build/coverage/unit
24+
TEST_INT_COV = build/coverage/int
25+
TEST_ALL_COV = build/coverage/all
26+
27+
# Targets
28+
.PHONY: all \
29+
test test-unit test-int lint coverage \
30+
clean fullclean
31+
32+
.DELETE_ON_ERROR:
33+
34+
all: build test
35+
36+
build: build/$(MODULE_JS) build/$(MODULE_MIN_JS) build/tracevis
37+
38+
build/$(MODULE_JS): browser.js node_modules $(SRC_FILES)
39+
mkdir -p $(@D)
40+
$(BROWSERIFY) -x node_modules/d3/index-browserify.js $(BROWSERIFY_OPTS) $< > $@
41+
42+
build/$(MODULE_MIN_JS): build/$(MODULE_JS)
43+
$(UGLIFY) $(UGLIFY_OPTS) $< > $@
44+
45+
build/tracevis: bootstrap css trace.html | build/tracevis/js
46+
mkdir -p $@
47+
cp -r $^ $@
48+
sed -e "s|node_modules/d3/d3.js|js/d3.min.js|" -e "s|build/$(MODULE_JS)|js/$(MODULE_MIN_JS)|" trace.html > build/tracevis/trace.html
49+
@echo
50+
51+
build/tracevis/js: build/$(MODULE_JS) build/$(MODULE_MIN_JS) node_modules/d3/d3.min.js
52+
rm -rf $@
53+
mkdir -p $@
54+
cp $^ $@
55+
56+
dist: test dist/$(MODULE_TAR_GZ)
57+
58+
dist/$(MODULE_TAR_GZ): build/tracevis
59+
mkdir -p $(@D)
60+
tar cfzC $@ build tracevis
61+
@echo
62+
63+
test: coverage
64+
65+
test-unit: $(TEST_UNIT_COV) lint
66+
67+
$(TEST_UNIT_COV): $(TEST_UNIT_FILES) $(SRC_FILES) | node_modules
68+
rm -rf $@
69+
$(MOCHA) $(MOCHA_OPTS) $(TEST_UNIT_FILES)
70+
# Instanbul instrumentation appears to mess up stack traces, so we run it after
71+
# ensuring the tests are passing
72+
$(ISTANBUL) cover $(MOCHA) --dir $@ -x **/lib/render/** --report none -- $(MOCHA_OPTS) $(TEST_UNIT_FILES)
73+
74+
test-int: $(TEST_INT_COV)
75+
76+
build/instrumentation:
77+
mkdir -p $@
78+
79+
build/instrumentation/lib: $(SRC_FILES)
80+
rm -rf $@
81+
mkdir -p $(@D)
82+
$(ISTANBUL) instrument lib --output $@
83+
84+
build/instrumentation/%.js: %.js | build/instrumentation
85+
cp $< $@
86+
87+
build/instrumentation/$(MODULE_JS): build/instrumentation/browser.js build/instrumentation/index.js node_modules build/instrumentation/lib
88+
$(BROWSERIFY) -x node_modules/d3/index-browserify.js $< > $@
89+
90+
build/instrumentation/$(MODULE): build/tracevis build/instrumentation/$(MODULE_JS)
91+
rm -rf $@
92+
cp -r $< $@
93+
cp build/instrumentation/$(MODULE_JS) $@/js/$(MODULE_MIN_JS)
94+
95+
$(TEST_INT_COV): $(TEST_INT_FILES) build/instrumentation/$(MODULE)
96+
mkdir -p $(@D)
97+
$(PHANTOMJS) $<
98+
touch $@
99+
@echo
100+
101+
coverage: $(TEST_ALL_COV)
102+
103+
$(TEST_ALL_COV): $(TEST_UNIT_COV) $(TEST_INT_COV)
104+
rm -rf $@
105+
$(ISTANBUL) report --root build/coverage --dir $@ lcov
106+
107+
lint: build/lint
108+
109+
build/lint: $(SRC_FILES) $(TEST_FILES)
110+
mkdir -p $(@D)
111+
$(JSHINT) $?
112+
touch $@
113+
@echo
13114

14115
clean:
116+
rm -rf build dist
117+
118+
fullclean: clean
15119
rm -rf ./node_modules
16120

17-
.PHONY: test clean
121+
node_modules: package.json
122+
$(NPM) install

tools/tracevis/README.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
Running Visualization
2-
=====================
1+
ParSeq Trace Visualization
2+
==========================
33

4-
To run the visualizations in your browser, add this directory to any web
5-
server.
4+
This project includes a trace visualizer for
5+
[https://github.com/linkedin/parseq](ParSeq) traces.
66

7-
Probably the easiest approach is to use Python's SimpleHTTPServer from
8-
this directory. To start SimpleHTTPServer on port 8888 use:
97

10-
```sh
11-
python -m SimpleHTTPServer 8888
12-
```
8+
Building
9+
========
1310

14-
Then connect to [http://localhost:8888/trace.html](http://localhost:8888/trace.html).
11+
To build the trace visualizer, use `make dist`. This creates a package for the
12+
trace visualizer at `dist/parseq-tracevis.tar.gz`.
1513

16-
Running Unit Tests for Visualization
17-
====================================
1814

19-
The unit tests requires node package manager (npm). Once it is installed, use
20-
`make test` to run the tests.
15+
Running the Trace Visualizer
16+
============================
17+
18+
To run the trace visualizer, extract `parseq-tracevis.tar.gz` and open
19+
index.html in a browser. The tool can also be hosted from a web server.
20+
21+
For coding / debugging, the trace visualizer can also be run from the directory
22+
that hosts this README.
23+
24+
More Info
25+
=========
26+
27+
For more information, see the [ParSeq trace wiki](https://github.com/linkedin/parseq/wiki/Tracing#wiki-trace-tools).
28+
29+
License
30+
=======
31+
32+
This tool is licensed under the terms of the Apache License, Version 2.0.

tools/tracevis/browser.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright 2012 LinkedIn, Inc
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
6+
* use this file except in compliance with the License. You may obtain a copy of
7+
* the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
global.parseqTracevis = require("./index");

tools/tracevis/css/table.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
max-width: 20em;
3535
}
3636

37+
.tableview td .expandable {
38+
cursor: pointer;
39+
}
40+
3741
.tableview td:last-child {
3842
width: 50%;
3943
}
@@ -52,7 +56,7 @@
5256
width: 100%;
5357
padding: 0;
5458
margin: 0;
55-
resize: none;
59+
resize: vertical;
5660
}
5761

5862
.tableview .success {

tools/tracevis/css/waterfall.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
cursor: pointer;
1717
}
1818

19-
.waterfallview .axis path,
20-
.waterfallview .axis line {
19+
.waterfallview .x-axis path,
20+
.waterfallview .x-axis line {
2121
pointer-events: none;
2222
fill: none;
2323
stroke: black;
2424
shape-rendering: crispEdges;
25-
stroke-opacity: .2;
25+
stroke-opacity: .1;
2626
}
2727

28-
.waterfallview .axis.grid line.tick.minor {
28+
.waterfallview .x-axis .minor-grid line {
2929
stroke-opacity: .05;
3030
}
3131

tools/tracevis/index.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
/*
2-
* Copyright 2012 LinkedIn, Inc
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5-
* use this file except in compliance with the License. You may obtain a copy of
6-
* the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13-
* License for the specific language governing permissions and limitations under
14-
* the License.
15-
*/
16-
17-
require('./lib/dig');
18-
require('./js/trace');
19-
require('./js/graphviz');
1+
module.exports = {
2+
trace: {
3+
parse: require("./lib/trace/parse"),
4+
excludeUserTasks: require("./lib/trace/exclude").userTasks,
5+
excludeSystemTasks: require("./lib/trace/exclude").systemTasks,
6+
excludeParentTasks: require("./lib/trace/exclude").parentTasks
7+
},
8+
renderGraphviz: require("./lib/render/graphviz"),
9+
renderTable: require("./lib/render/table"),
10+
renderWaterfall: require("./lib/render/waterfall")
11+
};

0 commit comments

Comments
 (0)