Skip to content

Commit

Permalink
Add stack trace and profiler outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
lo5 committed Jan 15, 2015
1 parent ecd6440 commit 490bbf6
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 15 deletions.
13 changes: 6 additions & 7 deletions src/core/components/notebook.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,8 @@ Flow.Notebook = (_, _renderers) ->
displayKeyboardShortcuts = ->
$('#keyboardShortcutsDialog').modal()

displayCloudStatus = ->
_.insertAndExecuteCell 'cs', 'getCloud'

displayTimeline = ->
_.insertAndExecuteCell 'cs', 'getTimeline'
executeCommand = (command) -> ->
_.insertAndExecuteCell 'cs', command

displayAbout = ->
$('#aboutDialog').modal()
Expand Down Expand Up @@ -421,9 +418,11 @@ Flow.Notebook = (_, _renderers) ->
]
,
createMenu 'Admin', [
createMenuItem 'Cloud Status', displayCloudStatus
createMenuItem 'Timeline', displayTimeline
createMenuItem 'Cloud Status', executeCommand 'getCloud'
createMenuItem 'Download Logs', goToUrl '/Logs/download'
createMenuItem 'Profiler', executeCommand 'getProfile'
createMenuItem 'Stack Trace', executeCommand 'getStackTrace'
createMenuItem 'Timeline', executeCommand 'getTimeline'
]
,
createMenu 'Help', [
Expand Down
6 changes: 6 additions & 0 deletions src/ext/components/h2o.jade
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ script(type="text/html" id="flow-cloud-output")

script(type="text/html" id="flow-timeline-output")
include timeline-output.jade

script(type="text/html" id="flow-profile-output")
include profile-output.jade

script(type="text/html" id="flow-stacktrace-output")
include stacktrace-output.jade
20 changes: 20 additions & 0 deletions src/ext/components/profile-output.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
H2O.ProfileOutput = (_, _profile) ->
_activeNode = signal null

createNode = (index, count, stackTrace) ->
display = -> _activeNode self

self =
name: "Node #{index}"
caption: "Node #{index} (Count: #{count})"
stackTrace: stackTrace
display: display

_nodes = for stackTrace, i in _profile.stacktraces
createNode i, _profile.counts[i], stackTrace

_activeNode head _nodes

nodes: _nodes
activeNode: _activeNode
template: 'flow-profile-output'
16 changes: 16 additions & 0 deletions src/ext/components/profile-output.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.flow-widget.flow-profile-output
h3.flow-hint
i.fa.fa-wrench
span Profiler

div
| Select Node:
select(data-bind="options:nodes, optionsText:'name', value:activeNode, optionsCaption:'(Select)'")

// ko with:activeNode
h4(data-bind='text:caption')
pre(data-bind='text:stackTrace')
// /ko
// /ko
27 changes: 27 additions & 0 deletions src/ext/components/stacktrace-output.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
H2O.StackTraceOutput = (_, _stackTrace) ->
_activeNode = signal null

createThread = (thread) ->
lines = split thread, '\n'

title: head lines
stackTrace: join (tail lines), '\n'

createNode = (node) ->
display = -> _activeNode self

self =
name: node._node
timestamp: new Date node._time
threads: (createThread thread for thread in node._traces)
display: display

_nodes = for node in _stackTrace.traces
createNode node

_activeNode head _nodes

nodes: _nodes
activeNode: _activeNode
template: 'flow-stacktrace-output'

18 changes: 18 additions & 0 deletions src/ext/components/stacktrace-output.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.flow-widget.flow-stacktrace-output
h3.flow-hint
i.fa.fa-wrench
span Stack Trace

div
| Select Node:
select(data-bind="options:nodes, optionsText:'name', value:activeNode, optionsCaption:'(Select)'")


// ko with:activeNode
h4(data-bind='text:timestamp')
// ko foreach:threads
h5(data-bind='text:title')
pre(data-bind='text:stackTrace')
// /ko
// /ko
6 changes: 3 additions & 3 deletions src/ext/components/timeline-output.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ H2O.TimelineOutput = (_, _timeline) ->
'Bytes'
]

_events = signal null
_data = signal null
_timestamp = signal Date.now()

createEvent = (event) ->
Expand Down Expand Up @@ -54,7 +54,7 @@ H2O.TimelineOutput = (_, _timeline) ->
trs = for event in timeline.events
tr (td cell for cell in createEvent event)

_events Flow.HTML.render 'div',
_data Flow.HTML.render 'div',
grid [
table [
thead tr ths
Expand All @@ -81,9 +81,9 @@ H2O.TimelineOutput = (_, _timeline) ->

updateTimeline _timeline

data: _data
isLive: _isLive
isBusy: _isBusy
events: _events
toggleRefresh: toggleRefresh
refresh: refresh
template: 'flow-timeline-output'
Expand Down
6 changes: 3 additions & 3 deletions src/ext/components/timeline-output.jade
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.flow-widget.flow-cloud-output
.flow-widget.flow-timeline-output
h3.flow-hint
i.fa.fa-cloud
i.fa.fa-clock-o
span Timeline

.flow-panel
Expand All @@ -14,4 +14,4 @@
| Refresh
// /ko
.flow-plot(data-bind='raw:events')
.flow-plot(data-bind='raw:data')
2 changes: 2 additions & 0 deletions src/ext/modules/application-context.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ H2O.ApplicationContext = (_) ->
_.requestPutObject = do slot
_.requestCloud = do slot
_.requestTimeline = do slot
_.requestProfile = do slot
_.requestStackTrace = do slot
_.requestRemoveAll = do slot
_.requestAbout = do slot
_.inspect = do slot
Expand Down
12 changes: 10 additions & 2 deletions src/ext/modules/proxy.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ H2O.Proxy = (_) ->
go null, head result.frames

requestJobs = (go) ->
doGet '/Jobs.json', (error, result) ->
doGet '/3/Jobs.json', (error, result) ->
if error
go new Flow.Error 'Error fetching jobs', error
else
Expand All @@ -83,7 +83,7 @@ H2O.Proxy = (_) ->
requestJob = (key, go) ->
#opts = key: encodeURIComponent key
#requestWithOpts '/Job.json', opts, go
doGet "/Jobs.json/#{encodeURIComponent key}", (error, result) ->
doGet "/3/Jobs.json/#{encodeURIComponent key}", (error, result) ->
if error
go new Flow.Error "Error fetching job '#{key}'", error
else
Expand Down Expand Up @@ -219,6 +219,12 @@ H2O.Proxy = (_) ->
requestTimeline = (go) ->
doGet '/3/Timeline.json', go

requestProfile = (depth, go) ->
doGet "/3/Profiler.json?depth=#{depth}", go

requestStackTrace = (go) ->
doGet '/3/JStack.json', go

requestRemoveAll = (go) ->
doGet '/3/RemoveAll.json', go

Expand Down Expand Up @@ -253,6 +259,8 @@ H2O.Proxy = (_) ->
link _.requestPutObject, requestPutObject
link _.requestCloud, requestCloud
link _.requestTimeline, requestTimeline
link _.requestProfile, requestProfile
link _.requestStackTrace, requestStackTrace
link _.requestRemoveAll, requestRemoveAll
link _.requestAbout, requestAbout

Expand Down
29 changes: 29 additions & 0 deletions src/ext/modules/routines.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ H2O.Routines = (_) ->
extendTimeline = (timeline) ->
render_ timeline, -> H2O.TimelineOutput _, timeline

extendStackTrace = (stackTrace) ->
render_ stackTrace, -> H2O.StackTraceOutput _, stackTrace

extendProfile = (profile) ->
render_ profile, -> H2O.ProfileOutput _, profile

extendFrames = (frames) ->
render_ frames, -> H2O.FramesOutput _, frames
frames
Expand Down Expand Up @@ -1151,6 +1157,27 @@ H2O.Routines = (_) ->
getTimeline = ->
_fork requestTimeline

requestStackTrace = (go) ->
_.requestStackTrace (error, stackTrace) ->
if error
go error
else
go null, extendStackTrace stackTrace

getStackTrace = ->
_fork requestStackTrace

requestProfile = (depth, go) ->
_.requestProfile depth, (error, profile) ->
if error
go error
else
go null, extendProfile profile

getProfile = (opts) ->
opts = depth: 10 unless opts
_fork requestProfile, opts.depth

loadScript = (path, go) ->
onDone = (script, status) -> go null, script:script, status:status
onFail = (jqxhr, settings, error) -> go error #TODO use framework error
Expand Down Expand Up @@ -1237,4 +1264,6 @@ H2O.Routines = (_) ->
getPredictions: getPredictions
getCloud: getCloud
getTimeline: getTimeline
getProfile: getProfile
getStackTrace: getStackTrace

0 comments on commit 490bbf6

Please sign in to comment.