X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5ac72e336a49d5a07e9ee36ba1f50473c57c45ec..f59d6d76acf9c6f5bb95c5902b2c9a1cca427e93:/apps/workbench/app/assets/javascripts/event_log.js diff --git a/apps/workbench/app/assets/javascripts/event_log.js b/apps/workbench/app/assets/javascripts/event_log.js index 31c30c817c..29ea74c417 100644 --- a/apps/workbench/app/assets/javascripts/event_log.js +++ b/apps/workbench/app/assets/javascripts/event_log.js @@ -77,7 +77,7 @@ function processLogLineForChart( logLine ) { var datum = null; // the timestamp comes first - var timestamp = match[1].replace('_','T'); + var timestamp = match[1].replace('_','T') + 'Z'; // we are interested in "-- interval" recordings var intervalMatch = match[6].match(/(.*) -- interval (.*)/); @@ -89,6 +89,12 @@ function processLogLineForChart( logLine ) { dsum += parseFloat(intervalData[i]); } datum = dsum/dt; + + if( datum < 0 ) { + // not interested in negative deltas + return; + } + rawDetailData = intervalMatch[2]; // for the series name use the task number (4th term) and then the first word after 'crunchstat:' @@ -96,10 +102,12 @@ function processLogLineForChart( logLine ) { // special calculation for cpus if( /-cpu$/.test(series) ) { - // divide the stat by the number of cpus - var cpuCountMatch = intervalMatch[1].match(/(\d+) cpus/); - if( cpuCountMatch ) { - datum = datum / cpuCountMatch[1]; + // divide the stat by the number of cpus unless the time count is less than the interval length + if( dsum.toFixed(1) > dt.toFixed(1) ) { + var cpuCountMatch = intervalMatch[1].match(/(\d+) cpus/); + if( cpuCountMatch ) { + datum = datum / cpuCountMatch[1]; + } } } @@ -182,11 +190,11 @@ function addJobGraphDatum(timestamp, datum, series, rawDetailData) { var shifted = []; // now let's see about "scrolling" the graph, dropping entries that are too old (>10 minutes) while( jobGraphData.length > 0 - && (Date.parse( jobGraphData[0]['t'] ).valueOf() + 10*60000 < Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf()) ) { + && (Date.parse( jobGraphData[0]['t'] ) + 10*60000 < Date.parse( jobGraphData[jobGraphData.length-1]['t'] )) ) { shifted.push(jobGraphData.shift()); } if( shifted.length > 0 ) { - // from those that we dropped, are any of them maxima? if so we need to rescale + // from those that we dropped, were any of them maxima? if so we need to rescale jobGraphSeries.forEach( function(series) { // test that every shifted entry in this series was either not a number (in which case we don't care) // or else approximately (to 2 decimal places) smaller than the scaled maximum (i.e. 1), @@ -215,10 +223,13 @@ function addJobGraphDatum(timestamp, datum, series, rawDetailData) { }); } // add a 10 minute old null data point to keep the chart honest if the oldest point is less than 9.9 minutes old - if( jobGraphData.length > 0 - && (Date.parse( jobGraphData[0]['t'] ).valueOf() + 9.9*60000 > Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf()) ) { - var tenMinutesBefore = (new Date(Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf() - 600*1000)).toISOString().replace('Z',''); - jobGraphData.unshift( { 't': tenMinutesBefore } ); + if( jobGraphData.length > 0 ) { + var earliestTimestamp = jobGraphData[0]['t']; + var mostRecentTimestamp = jobGraphData[jobGraphData.length-1]['t']; + if( (Date.parse( earliestTimestamp ) + 9.9*60000 > Date.parse( mostRecentTimestamp )) ) { + var tenMinutesBefore = (new Date(Date.parse( mostRecentTimestamp ) - 600*1000)).toISOString(); + jobGraphData.unshift( { 't': tenMinutesBefore } ); + } } } @@ -256,7 +267,7 @@ function createJobGraph(elementName) { var datum = options.data[index][series]; var point = '' point += "
"; var labelMatch = options.labels[sortedIndex].match(/^T(\d+)-(.*)/); point += 'Task ' + labelMatch[1] + ' ' + labelMatch[2]; @@ -316,7 +327,9 @@ function isJobSeriesRescalable( series ) { $(document).on('arv-log-event', '#log_graph_div', function(event, eventData) { if( eventData.properties.text ) { - processLogLineForChart( eventData.properties.text ); + eventData.properties.text.split('\n').forEach( function( logLine ) { + processLogLineForChart( logLine ); + } ); } } ); @@ -330,9 +343,16 @@ $(document).on('ready ajax:complete', function() { window.redraw = false; createJobGraph($(graph_div).attr('id')); + var object_uuid = $(graph_div).data('object-uuid'); + // if there are any listeners for this object uuid or "all", we will trigger the event + var matches = ".arv-log-event-listener[data-object-uuid=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuids~=\"" + object_uuid + "\"]"; $(document).trigger('ajax:send'); - $.get('/jobs/' + $(graph_div).data('object-uuid') + '/push_logs.js'); + $.get('/jobs/' + $(graph_div).data('object-uuid') + '/logs.json', function(data) { + data.forEach( function( entry ) { + $(matches).trigger('arv-log-event', entry); + }); + }); setInterval( function() { if( recreate ) {