import _ from 'lodash'; import Metric from './Metric.jsx'; import { metricToFormatter } from './util/Utils.js'; import React from 'react'; import { Col, Progress, Row } from 'antd'; import './../../css/health-pane.css'; const TrafficIndicator = ({healthStat}) => { return ( null} /> ); }; export default class HealthPane extends React.Component { getRequestRate(metrics) { return _.sumBy(metrics, 'requestRate'); } getAvgSuccessRate(metrics) { return _.meanBy(metrics, 'successRate'); } getHealthClassName(successRate) { if (_.isNil(successRate) || _.isNaN(successRate)) { return "health-unknown"; } if (successRate < 0.4) { return "health-bad"; } if (successRate > 0.95) { return "health-good"; } return "health-neutral"; } getHealthStats() { let inboundSr = this.getAvgSuccessRate(this.props.upstreamMetrics); let outboundSr = this.getAvgSuccessRate(this.props.downstreamMetrics); let sr = this.props.currentSr; return { inbound: { requests: metricToFormatter["REQUEST_RATE"](this.getRequestRate(this.props.upstreamMetrics)), health: this.getHealthClassName(inboundSr) }, outbound: { requests: metricToFormatter["REQUEST_RATE"](this.getRequestRate(this.props.downstreamMetrics)), health: this.getHealthClassName(outboundSr) }, current: { health: this.getHealthClassName(sr) } }; } render() { let stats = this.getHealthStats(); return (
{this.props.entityType} Health
« {_.size(this.props.upstreamMetrics)} {this.props.entityType}s
 
{this.props.entity}
{_.size(this.props.downstreamMetrics)} {this.props.entityType}s »
); } }