2021-01-03 18:15:44 +05:30
import React , { useEffect } from 'react' ;
import { Tabs , Card , Row , Col } from 'antd' ;
import { connect } from 'react-redux' ;
2021-01-07 19:59:48 +05:30
import { useParams , RouteComponentProps } from "react-router-dom" ;
import { withRouter } from "react-router" ;
2021-01-03 18:15:44 +05:30
2021-01-07 19:59:48 +05:30
import { getServicesMetrics , metricItem , getTopEndpoints , topEndpointListItem , GlobalTime , updateTimeInterval } from '../../actions' ;
2021-01-03 18:15:44 +05:30
import { StoreState } from '../../reducers'
import LatencyLineChart from "./LatencyLineChart"
import RequestRateChart from './RequestRateChart'
import ErrorRateChart from './ErrorRateChart'
import TopEndpointsTable from './TopEndpointsTable' ;
const { TabPane } = Tabs ;
2021-01-07 19:59:48 +05:30
interface ServicesMetricsProps extends RouteComponentProps < any > {
2021-01-03 18:15:44 +05:30
serviceMetrics : metricItem [ ] ,
getServicesMetrics : Function ,
topEndpointsList : topEndpointListItem [ ] ,
getTopEndpoints : Function ,
globalTime : GlobalTime ,
2021-01-07 19:59:48 +05:30
updateTimeInterval : Function ,
2021-01-03 18:15:44 +05:30
}
const _ServiceMetrics = ( props : ServicesMetricsProps ) = > {
const params = useParams < { servicename? : string ; } > ( ) ;
useEffect ( ( ) = > {
props . getServicesMetrics ( params . servicename , props . globalTime ) ;
props . getTopEndpoints ( params . servicename , props . globalTime ) ;
} , [ props . globalTime , params . servicename ] ) ;
2021-01-07 19:59:48 +05:30
const onTracePopupClick = ( timestamp :number ) = > {
props . updateTimeInterval ( 'custom' , [ ( timestamp / 1000000 ) - 5 * 60 * 1000 , ( timestamp / 1000000 ) ] ) // updateTimeInterval takes second range in ms -- give -5 min to selected time,
props . history . push ( '/traces' )
}
2021-01-03 18:15:44 +05:30
return (
< Tabs defaultActiveKey = "1" >
< TabPane tab = "Application Metrics" key = "1" >
< Row gutter = { 32 } style = { { margin : 20 } } >
< Col span = { 12 } >
< Card bodyStyle = { { padding :10 } } >
2021-01-07 19:59:48 +05:30
< LatencyLineChart data = { props . serviceMetrics } popupClickHandler = { onTracePopupClick } / >
2021-01-03 18:15:44 +05:30
< / Card >
< / Col >
< Col span = { 12 } >
< Card bodyStyle = { { padding :10 } } >
< RequestRateChart data = { props . serviceMetrics } / >
< / Card >
< / Col >
< / Row >
< Row gutter = { 32 } style = { { margin : 20 } } >
< Col span = { 12 } >
< Card bodyStyle = { { padding :10 } } >
< ErrorRateChart data = { props . serviceMetrics } / >
< / Card >
< / Col >
< Col span = { 12 } >
< Card bodyStyle = { { padding :10 } } >
< TopEndpointsTable data = { props . topEndpointsList } / >
< / Card >
< / Col >
< / Row >
< / TabPane >
< TabPane tab = "External Calls" key = "2" >
< div style = { { margin : 20 } } > Coming Soon . . < / div >
< div className = "container" style = { { display : 'flex' , flexFlow : 'column wrap' } } >
< div className = 'row' >
< div className = 'col-md-6 col-sm-12 col-12' >
{ /* <ChartJSLineChart data={this.state.graphData} /> */ }
< / div >
< div className = 'col-md-6 col-sm-12 col-12' >
{ /* <ChartJSLineChart data={this.state.graphData} /> */ }
< / div >
< / div >
< / div >
< / TabPane >
< / Tabs >
) ;
}
const mapStateToProps = ( state : StoreState ) : { serviceMetrics : metricItem [ ] , topEndpointsList : topEndpointListItem [ ] , globalTime : GlobalTime } = > {
return { serviceMetrics : state.serviceMetrics , topEndpointsList : state.topEndpointsList , globalTime :state.globalTime } ;
} ;
2021-01-07 19:59:48 +05:30
export const ServiceMetrics = withRouter ( connect ( mapStateToProps , {
2021-01-03 18:15:44 +05:30
getServicesMetrics : getServicesMetrics ,
getTopEndpoints : getTopEndpoints ,
2021-01-07 19:59:48 +05:30
updateTimeInterval : updateTimeInterval ,
} ) ( _ServiceMetrics ) ) ;
2021-01-03 18:15:44 +05:30