Skip to content

Commit ab6ce58

Browse files
committed
Added a tooltip to the treemap that tells if a node will be traced.
1 parent c59073a commit ab6ce58

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

codepulse/src/main/resources/toserve/pages/traces/traces.js

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ $(document).ready(function(){
7272
})()
7373

7474

75+
Trace.instrumentedPackages = {}
76+
Trace.isInstrumentedNode = function isInstrumented(node){
77+
if(!node) return false
78+
79+
if(Trace.instrumentedPackages.hasOwnProperty(node.id)){
80+
return !!Trace.instrumentedPackages[node.id]
81+
}
82+
83+
return isInstrumented(node.parent)
84+
}
85+
7586
// When the `treemapColoringStateChanges` fires, use the current `legendData`
7687
// to generate a new treemap coloring function, and update the treemap's colors
7788
// with that.
@@ -105,10 +116,10 @@ $(document).ready(function(){
105116
var activeRecordingIds = Trace.getActiveRecordingIds(),
106117
allActivityId = Trace.allActivityRecordingId,
107118
allActivityColor = colorLegend[allActivityId],
108-
allActivityColorFaded = d3.interpolate('lightgray', allActivityColor)(.2)
119+
allActivityColorFaded = d3.interpolate('lightgray', allActivityColor)(.2),
120+
instrumentedPackages = Trace.instrumentedPackages
109121

110122
function countActiveCoverings(coverage){
111-
// if(!coverage) return 0
112123
var count = 0
113124
coverage.forEach(function(id){
114125
if(activeRecordingIds.has(id)){
@@ -118,9 +129,10 @@ $(document).ready(function(){
118129
return count
119130
}
120131

121-
return function(node){
132+
var base = function(node){
122133
if(ignoredKinds.has(node.kind)) return 'grey'
123134

135+
124136
var coverage = Trace.coverageSets[node.id],
125137
numCovered = countActiveCoverings(coverage)
126138

@@ -140,6 +152,12 @@ $(document).ready(function(){
140152

141153
return entry? entry : 'yellow'
142154
}
155+
156+
return function(node){
157+
var baseColor = base(node)
158+
if(Trace.isInstrumentedNode(node)) return baseColor
159+
else return d3.interpolate('darkgray', baseColor)(.2)
160+
}
143161
}
144162

145163
treemapColoring.latest = coloringFunc
@@ -168,6 +186,11 @@ $(document).ready(function(){
168186

169187
var controller = new PackageController(Trace.fullTree, $('#packages'), $('#totals'), $('#clear-selections-button'))
170188

189+
controller.instrumentedWidgets.onValue(function(map){
190+
Trace.instrumentedPackages = map
191+
Trace.treemapColoringStateChanges.push('Instrumented Packages Changed')
192+
})
193+
171194
/**
172195
* An Rx Property that represents the treemap's TreeData as it
173196
* changes due to the PackageWidgets' selection state.
@@ -353,7 +376,21 @@ $(document).ready(function(){
353376
return container
354377
}
355378

356-
return padDiv.append(recurse(0))
379+
var result = $('<div>')
380+
381+
// added the padded div that holds the ancestors list
382+
result.append(padDiv.append(recurse(0)))
383+
384+
// if the node isn't "instrumented", add a div that says so
385+
if(!Trace.isInstrumentedNode(node)){
386+
var noTraceBadge = $('<div>')
387+
.addClass('notrace-badge')
388+
.text('This method is not marked for tracing')
389+
.prepend('<i class="fa fa-times">')
390+
result.append(noTraceBadge)
391+
}
392+
393+
return result
357394
}
358395
}
359396
})()

codepulse/src/main/resources/toserve/pages/traces/treemap-tooltip.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
border: none;
44
pointer-events: none;
55
max-width: initial;
6+
7+
font-size: 12px;
8+
line-height: 14px;
69
}
710

811
.qtip.treemap-tooltip .qtip-titlebar {
@@ -15,6 +18,7 @@
1518
.qtip.treemap-tooltip .qtip-content {
1619
color: white;
1720
padding: 0;
21+
overflow: visible;
1822
}
1923

2024
.qtip.treemap-tooltip .content-padded {
@@ -47,4 +51,15 @@
4751
margin-right: 5px;
4852
padding: 0 4px;
4953
border-radius: 5px;
54+
}
55+
56+
.qtip.treemap-tooltip .notrace-badge {
57+
position: absolute;
58+
top: calc(100% + 2px);
59+
width: 100%;
60+
padding: 2px 4px;
61+
box-sizing: border-box;
62+
63+
background-color: rgba(0,0,0,0.7);
64+
color: #DBAF00;
5065
}

0 commit comments

Comments
 (0)