[ARVADOS] updated: bce765931ead12469cb1d363a7974c3380191df6
git at public.curoverse.com
git at public.curoverse.com
Sat Nov 15 07:41:19 EST 2014
Summary of changes:
apps/workbench/app/assets/javascripts/event_log.js | 35 ++++++++++++++++------
apps/workbench/app/helpers/jobs_helper.rb | 17 +++++++++--
apps/workbench/app/views/jobs/_show_log.html.erb | 8 +++--
3 files changed, 45 insertions(+), 15 deletions(-)
via bce765931ead12469cb1d363a7974c3380191df6 (commit)
from 23cebe864f7fe128aa784ef31fc14d0f3455aea5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit bce765931ead12469cb1d363a7974c3380191df6
Author: Phil Hodgson <bitbucket at philhodgson.net>
Date: Sat Nov 15 13:41:13 2014 +0100
4233: redraw graph when processing log events
- still very naive
- still does not scale y-axis
- does not try to limit x axis timeline to 20 minutes: just keeps growing
- seems intolerably inefficient - optimization on several fronts almost certainly still required:
- initial draw on first page load should do much less client-side processing
- at accelerated speeds, it cannot keep up, and if we expect so much data throughput we'd want to devise a way to only redraw once in a while to save needless processor work
diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js
index c081492..10fe5be 100644
--- a/apps/workbench/app/assets/javascripts/event_log.js
+++ b/apps/workbench/app/assets/javascripts/event_log.js
@@ -74,18 +74,35 @@ function processLogLineForChart( logLine, jobGraphSeries, jobGraphData ) {
var datum = (dsum/dt).toFixed(4);
var preamble = match[1].trim().split(' ');
var timestamp = preamble[0].replace('_','T');
- var found = false;
- for( var i=0; i < jobGraphData.length; i++ ) {
- if( jobGraphData[i]['t'] == timestamp ) {
- jobGraphData[i][series] = datum;
- found = true;
- break;
- }
- }
- if( !found ){
+ var xpoints = $.grep( jobGraphData, function(e){ return e['t'] === timestamp; });
+ if(xpoints.length) {
+ // xpoints[0] is the x point that that matched the timestamp and so already existed: add the new datum
+ xpoints[0][series] = datum;
+ } else {
var entry = { 't': timestamp };
entry[series] = datum;
jobGraphData.push( entry );
}
}
}
+
+$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
+ if( eventData.properties.text ) {
+ var series_length = jobGraphSeries.length;
+ processLogLineForChart( eventData.properties.text, jobGraphSeries, jobGraphData);
+ if( series_length < jobGraphSeries.length) {
+ // series have changed, draw entirely new graph
+ $('#log_graph_div').html('');
+ jobGraph = Morris.Line({
+ element: 'log_graph_div',
+ data: jobGraphData,
+ xkey: 't',
+ ykeys: jobGraphSeries,
+ labels: jobGraphSeries
+ });
+ } else {
+ jobGraph.setData( jobGraphData );
+ }
+ }
+
+} );
\ No newline at end of file
diff --git a/apps/workbench/app/helpers/jobs_helper.rb b/apps/workbench/app/helpers/jobs_helper.rb
index 22d74c1..ec6fccf 100644
--- a/apps/workbench/app/helpers/jobs_helper.rb
+++ b/apps/workbench/app/helpers/jobs_helper.rb
@@ -18,9 +18,20 @@ module JobsHelper
return results
end
- def stderr_log_records(job_uuids)
- Log.where(event_type: 'stderr',
- object_uuid: job_uuids).order('id DESC').results
+ def stderr_log_records(job_uuids, extra_filters = nil)
+ filters = [["event_type", "=", "stderr"],
+ ["object_uuid", "in", job_uuids]]
+ filters += extra_filters if extra_filters
+ last_entry = Log.order('id DESC').limit(1).filter(filters).results.first
+ if last_entry
+ filters += [["event_at", ">=", last_entry.event_at - 3.minutes]]
+ Log.order('id DESC')
+ .limit(10000)
+ .filter(filters)
+ .results
+ else
+ []
+ end
end
end
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index 2513883..75edf59 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -1,6 +1,8 @@
<% if !@object.log %>
-<div id="log_graph_div" data-object-uuid="<%= @object.uuid %>"></div>
+<div id="log_graph_div"
+ class="arv-log-event-listener"
+ data-object-uuid="<%= @object.uuid %>"></div>
<% log_history = stderr_log_history([@object.uuid]) %>
@@ -18,8 +20,8 @@
<%= javascript_tag do %>
var jobGraphData = [];
var jobGraphSeries = [];
- <% stderr_log_records([@object.uuid]).each.with_index do |log_record, index| %>
- <% puts log_record.to_yaml %>
+ <% stderr_log_records([@object.uuid],[['properties','~','crunchstat:.*-- interval']])
+ .each.with_index do |log_record, index| %>
var logLine = '<%=j log_record.properties[:text] %>';
processLogLineForChart( logLine, jobGraphSeries, jobGraphData );
<% end %>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list