2017-02-24 14:13:10 +02:00
|
|
|
import { IntlProvider } from 'react-intl-redux';
|
|
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
|
|
import { Provider } from 'react-redux';
|
2017-03-22 16:38:04 +02:00
|
|
|
import qs from 'querystring';
|
2017-02-20 18:15:36 +02:00
|
|
|
import a11y from 'react-a11y';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import React from 'react';
|
2017-03-27 16:20:48 +03:00
|
|
|
import Perf from 'react-addons-perf';
|
2017-02-24 14:13:10 +02:00
|
|
|
|
|
|
|
import App from '@containers/app';
|
2017-03-27 18:48:26 +03:00
|
|
|
import MockStateTesting from '@mock-states/testing';
|
|
|
|
import MockState from '@mock-states';
|
2017-03-21 13:11:36 +02:00
|
|
|
import LeakDatasets from './dataset-leak.json';
|
|
|
|
import NormalDatasets from './dataset-normal.json';
|
2017-02-24 14:13:10 +02:00
|
|
|
import Store from '@state/store';
|
2016-10-20 04:14:26 +03:00
|
|
|
|
2016-10-25 22:36:05 +03:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
a11y(React, {
|
|
|
|
ReactDOM
|
|
|
|
});
|
2017-03-27 16:20:48 +03:00
|
|
|
|
|
|
|
window.Perf = Perf;
|
2016-10-25 22:36:05 +03:00
|
|
|
}
|
|
|
|
|
2017-03-22 16:41:53 +02:00
|
|
|
const states = {
|
|
|
|
all: MockState,
|
|
|
|
testing: MockStateTesting
|
2017-03-22 19:10:10 +02:00
|
|
|
};
|
2017-03-22 16:41:53 +02:00
|
|
|
|
2017-03-22 16:38:04 +02:00
|
|
|
const query = qs.parse(window.location.search.replace(/^\?/, ''));
|
2017-03-22 16:41:53 +02:00
|
|
|
const mockState = states[query.mock || 'testing'];
|
2017-03-22 16:38:04 +02:00
|
|
|
|
2017-03-20 21:46:44 +02:00
|
|
|
// node_memory_rss_bytes
|
|
|
|
// node_memory_heap_total_bytes
|
|
|
|
// node_memory_heap_used_bytes
|
|
|
|
// process_heap_bytes
|
|
|
|
// process_resident_memory_bytes
|
|
|
|
// process_virtual_memory_bytes
|
|
|
|
// process_cpu_seconds_total
|
|
|
|
// process_cpu_system_seconds_total
|
|
|
|
// process_cpu_user_seconds_total
|
|
|
|
// node_lag_duration_milliseconds
|
|
|
|
// http_request_duration_milliseconds
|
|
|
|
|
|
|
|
// node_memory_rss_bytes
|
|
|
|
// node_memory_heap_total_bytes
|
|
|
|
// node_memory_heap_used_bytes
|
|
|
|
// process_heap_bytes
|
|
|
|
// process_resident_memory_bytes
|
|
|
|
// process_virtual_memory_bytes
|
|
|
|
// process_cpu_seconds_total
|
|
|
|
// process_cpu_system_seconds_total
|
|
|
|
// process_cpu_user_seconds_total
|
|
|
|
// node_lag_duration_milliseconds
|
|
|
|
// http_request_duration_milliseconds
|
2017-03-20 19:43:26 +02:00
|
|
|
|
2017-03-17 21:27:15 +02:00
|
|
|
// TMP - ensure datasets are at least 2 hrs long - START
|
|
|
|
import getTwoHourDatasets from './utils/two-hour-metric-datasets';
|
2017-03-20 21:46:44 +02:00
|
|
|
const leakTwoHourLongDatasets = getTwoHourDatasets(LeakDatasets);
|
|
|
|
const normalTwoHourLongDatasets = getTwoHourDatasets(NormalDatasets);
|
2017-03-17 21:27:15 +02:00
|
|
|
// TMP - ensure datasets are at least 2 hrs long - END
|
|
|
|
|
|
|
|
// TMP - plug fake metric data - START
|
2017-03-20 21:46:44 +02:00
|
|
|
const isCrazy = (uuid) => uuid === 'crazy-cpu' ||
|
|
|
|
uuid === 'crazy-disk' || uuid === 'crazy-memory';
|
|
|
|
|
|
|
|
const isCPU = (uuid) => uuid === 'crazy-cpu'
|
|
|
|
|| uuid === '3e6ee79a-7453-4fc6-b9da-7ae1e41138ec';
|
|
|
|
|
|
|
|
const isDisk = (uuid) => uuid === 'crazy-disk'
|
|
|
|
|| uuid === '4e6ee79a-7453-4fc6-b9da-7ae1e41138ed';
|
|
|
|
|
|
|
|
const isMemory = (uuid) => uuid === 'crazy-memory'
|
|
|
|
|| uuid === '6e6ee79a-7453-4fc6-b9da-7ae1e41138ed';
|
|
|
|
|
|
|
|
const getDataset = (twoHourLongDatasets, uuid) => {
|
|
|
|
if(isCPU(uuid)) {
|
|
|
|
return twoHourLongDatasets.process_cpu_seconds_total;
|
|
|
|
}
|
|
|
|
if(isDisk(uuid)) {
|
2017-03-22 15:21:44 +02:00
|
|
|
return twoHourLongDatasets.process_heap_bytes.map((sample) =>
|
|
|
|
[
|
|
|
|
sample[0],
|
|
|
|
sample[1]/1024/1024
|
|
|
|
]
|
|
|
|
);
|
2017-03-20 21:46:44 +02:00
|
|
|
}
|
|
|
|
if(isMemory(uuid)) {
|
2017-03-22 15:21:44 +02:00
|
|
|
return twoHourLongDatasets.node_memory_heap_used_bytes.map((sample) =>
|
|
|
|
[
|
|
|
|
sample[0],
|
|
|
|
sample[1]/1024/1024
|
|
|
|
]
|
|
|
|
);
|
2017-03-20 21:46:44 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const datasets = MockState.metrics.data.datasets.map((dataset, index) => {
|
|
|
|
|
2017-03-22 15:21:44 +02:00
|
|
|
const data = isCrazy(dataset.uuid) && dataset.uuid !== 'crazy-cpu' ?
|
2017-03-20 21:46:44 +02:00
|
|
|
getDataset(leakTwoHourLongDatasets, dataset.uuid) :
|
|
|
|
getDataset(normalTwoHourLongDatasets, dataset.uuid);
|
|
|
|
|
2017-03-17 21:27:15 +02:00
|
|
|
return {
|
|
|
|
...dataset,
|
2017-03-20 21:46:44 +02:00
|
|
|
data: data
|
2017-03-17 21:27:15 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2017-03-20 19:43:26 +02:00
|
|
|
mockState.metrics.data.datasets = datasets;
|
2017-03-17 21:27:15 +02:00
|
|
|
// TMP - plug fake metric data - END
|
|
|
|
|
2017-02-20 18:15:36 +02:00
|
|
|
ReactDOM.render(
|
2017-03-20 19:43:26 +02:00
|
|
|
<Provider store={Store(mockState)}>
|
2017-02-24 14:13:10 +02:00
|
|
|
<IntlProvider>
|
|
|
|
<BrowserRouter>
|
|
|
|
<App />
|
|
|
|
</BrowserRouter>
|
|
|
|
</IntlProvider>
|
|
|
|
</Provider>,
|
2017-02-20 18:15:36 +02:00
|
|
|
document.getElementById('root')
|
|
|
|
);
|