update service latency metric upon ws data
This commit is contained in:
parent
7ec0ff79f8
commit
155f96c218
1 changed files with 12 additions and 14 deletions
|
@ -51,18 +51,23 @@ export default class App extends Component {
|
|||
|
||||
const [, name] = channel.split(':');
|
||||
|
||||
log('updating from channel:', channel);
|
||||
|
||||
const { metrics } = this.state;
|
||||
const graph = metrics.graph[name].slice(1);
|
||||
const newGraph = [data, ...graph];
|
||||
|
||||
log('adding data:', data);
|
||||
|
||||
this.setState((prevState, _props) => {
|
||||
const clone = Object.assign({}, prevState.metrics);
|
||||
clone.graph[name] = newGraph;
|
||||
this.setState(({ metrics: oldMetrics }, _props) => {
|
||||
const newMetrics = { ...oldMetrics };
|
||||
newMetrics.graph[name] = newGraph;
|
||||
|
||||
const [, latency] = data;
|
||||
newMetrics.status[name].latency = latency;
|
||||
|
||||
return {
|
||||
metrics: clone,
|
||||
metrics: newMetrics,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -128,19 +133,12 @@ export default class App extends Component {
|
|||
|
||||
return (
|
||||
<div className="dashboard">
|
||||
<h1>
|
||||
elstatus
|
||||
</h1>
|
||||
<h1>elstatus</h1>
|
||||
{this.state.loading ? (
|
||||
<div>
|
||||
Loading metrics...
|
||||
</div>
|
||||
<div>Loading metrics...</div>
|
||||
) : null}
|
||||
{this.state.error ? (
|
||||
<div>
|
||||
Error:
|
||||
{this.state.error}
|
||||
</div>
|
||||
<div>Error: {this.state.error}</div>
|
||||
) : null}
|
||||
{metrics}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue