graphs: directly stream docker stats
docker stats API caches the stat and reading it frequently gives back the same value. this trips our "rate" code into thinking rate is 0. one approach was to persist polling like we do now and ignore entries based on stats.read. this works fine but the streaming approach seems better since we don't need to poll anymore.
This commit is contained in:
@@ -43,10 +43,8 @@ let systemMemory = {};
|
||||
let systemCpus = {};
|
||||
let metricStream = null;
|
||||
|
||||
const LIVE_REFRESH_INTERVAL_MSECS = 500;
|
||||
|
||||
async function liveRefresh() {
|
||||
metricStream = await appsModel.getMetricStream(app.id, LIVE_REFRESH_INTERVAL_MSECS);
|
||||
metricStream = await appsModel.getMetricStream(app.id);
|
||||
metricStream.onerror = (error) => console.log('event stream error:', error);
|
||||
metricStream.onmessage = (message) => {
|
||||
const data = JSON.parse(message.data);
|
||||
|
||||
@@ -407,8 +407,8 @@ function create() {
|
||||
if (result.status !== 200) return [result];
|
||||
return [null, result.body];
|
||||
},
|
||||
async getMetricStream(id, intervalMsecs) {
|
||||
return new EventSource(`${API_ORIGIN}/api/v1/apps/${id}/metricstream?access_token=${accessToken}&intervalMsecs=${intervalMsecs}`);
|
||||
async getMetricStream(id) {
|
||||
return new EventSource(`${API_ORIGIN}/api/v1/apps/${id}/metricstream?access_token=${accessToken}`);
|
||||
},
|
||||
async repair(id, data) {
|
||||
let result;
|
||||
|
||||
Reference in New Issue
Block a user