links error to traces

This commit is contained in:
dhrubesh 2021-05-02 16:39:36 +05:30
parent ee69c3aed2
commit 7aeffacaa5
4 changed files with 37 additions and 4 deletions

View File

@ -3,4 +3,5 @@ export enum METRICS_PAGE_QUERY_PARAM {
startTime = "startTime", startTime = "startTime",
endTime = "endTime", endTime = "endTime",
service = "service", service = "service",
error = "error",
} }

View File

@ -37,6 +37,7 @@ const theme = "dark";
interface ErrorRateChartProps extends RouteComponentProps<any> { interface ErrorRateChartProps extends RouteComponentProps<any> {
data: metricItem[]; data: metricItem[];
onTracePopupClick: Function;
} }
interface ErrorRateChart { interface ErrorRateChart {
@ -54,6 +55,7 @@ class ErrorRateChart extends React.Component<ErrorRateChartProps> {
xcoordinate: 0, xcoordinate: 0,
ycoordinate: 0, ycoordinate: 0,
showpopUp: false, showpopUp: false,
firstpoint_ts: 0
// graphInfo:{} // graphInfo:{}
}; };
@ -65,17 +67,18 @@ class ErrorRateChart extends React.Component<ErrorRateChartProps> {
if (firstPoint) { if (firstPoint) {
// PNOTE - TODO - Is await needed in this expression? // PNOTE - TODO - Is await needed in this expression?
await this.setState({ this.setState({
xcoordinate: e.offsetX + 20, xcoordinate: e.offsetX + 20,
ycoordinate: e.offsetY, ycoordinate: e.offsetY,
showpopUp: true, showpopUp: true,
firstpoint_ts: this.props.data[firstPoint._index].timestamp,
// graphInfo:{...event} // graphInfo:{...event}
}); });
} }
}; };
gotoTracesHandler = () => { gotoTracesHandler = () => {
this.props.history.push(ROUTES.TRACES); this.props.onTracePopupClick(this.state.firstpoint_ts);
}; };
gotoAlertsHandler = () => { gotoAlertsHandler = () => {
@ -216,7 +219,7 @@ class ErrorRateChart extends React.Component<ErrorRateChartProps> {
return ( return (
<div> <div>
{this.GraphTracePopUp()} {this.GraphTracePopUp()}
<div style={{textAlign: "center"}}>Errors per sec</div> <div style={{ textAlign: "center" }}>Errors per sec</div>
<ChartJSLine <ChartJSLine
ref={this.chartRef} ref={this.chartRef}
data={data_chartJS} data={data_chartJS}

View File

@ -54,6 +54,23 @@ const _ServiceMetrics = (props: ServicesMetricsProps) => {
props.history.push(`${ROUTES.TRACES}?${urlParams.toString()}`); props.history.push(`${ROUTES.TRACES}?${urlParams.toString()}`);
}; };
const onErrTracePopupClick = (timestamp: number) => {
const currentTime = timestamp / 1000000;
const tPlusOne = timestamp / 1000000 + 1 * 60 * 1000;
props.updateTimeInterval("custom", [currentTime, tPlusOne]); // updateTimeInterval takes second range in ms -- give -5 min to selected time,
const urlParams = new URLSearchParams();
urlParams.set(METRICS_PAGE_QUERY_PARAM.startTime, currentTime.toString());
urlParams.set(METRICS_PAGE_QUERY_PARAM.endTime, tPlusOne.toString());
if (servicename) {
urlParams.set(METRICS_PAGE_QUERY_PARAM.service, servicename);
}
urlParams.set(METRICS_PAGE_QUERY_PARAM.error, "true");
props.history.push(`${ROUTES.TRACES}?${urlParams.toString()}`);
};
return ( return (
<Tabs defaultActiveKey="1"> <Tabs defaultActiveKey="1">
<TabPane tab="Application Metrics" key="1"> <TabPane tab="Application Metrics" key="1">
@ -77,7 +94,10 @@ const _ServiceMetrics = (props: ServicesMetricsProps) => {
<Row gutter={32} style={{ margin: 20 }}> <Row gutter={32} style={{ margin: 20 }}>
<Col span={12}> <Col span={12}>
<Card bodyStyle={{ padding: 10 }}> <Card bodyStyle={{ padding: 10 }}>
<ErrorRateChart data={props.serviceMetrics} /> <ErrorRateChart
onTracePopupClick={onErrTracePopupClick}
data={props.serviceMetrics}
/>
</Card> </Card>
</Col> </Col>

View File

@ -63,9 +63,18 @@ const _TraceFilter = (props: TraceFilterProps) => {
}) })
.then(() => { .then(() => {
const serviceName = urlParams.get(METRICS_PAGE_QUERY_PARAM.service); const serviceName = urlParams.get(METRICS_PAGE_QUERY_PARAM.service);
const errorTag = urlParams.get(METRICS_PAGE_QUERY_PARAM.error);
if (serviceName) { if (serviceName) {
handleChangeService(serviceName); handleChangeService(serviceName);
} }
if (errorTag) {
onTagFormSubmit({
tag_key: METRICS_PAGE_QUERY_PARAM.error,
tag_value: errorTag,
operator: "EQUAL",
});
}
}); });
}, []); }, []);