2023-08-16 12:18:56 +05:30
|
|
|
import Spinner from 'components/Spinner';
|
2023-07-20 12:02:21 +05:30
|
|
|
import { FeatureKeys } from 'constants/features';
|
2023-07-28 21:54:36 +05:30
|
|
|
import { PANEL_TYPES } from 'constants/queryBuilder';
|
2023-07-18 08:55:01 +05:30
|
|
|
import Graph from 'container/GridGraphLayout/Graph/';
|
|
|
|
|
import { GraphTitle } from 'container/MetricsApplication/constant';
|
|
|
|
|
import { getWidgetQueryBuilder } from 'container/MetricsApplication/MetricsApplication.factory';
|
|
|
|
|
import { latency } from 'container/MetricsApplication/MetricsPageQueries/OverviewQueries';
|
|
|
|
|
import { Card, GraphContainer } from 'container/MetricsApplication/styles';
|
2023-07-20 12:02:21 +05:30
|
|
|
import useFeatureFlag from 'hooks/useFeatureFlag';
|
2023-08-11 12:56:41 +05:30
|
|
|
import useResourceAttribute from 'hooks/useResourceAttribute';
|
|
|
|
|
import { resourceAttributesToTagFilterItems } from 'hooks/useResourceAttribute/utils';
|
2023-07-18 08:55:01 +05:30
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
|
import { EQueryType } from 'types/common/dashboard';
|
|
|
|
|
import { v4 as uuid } from 'uuid';
|
|
|
|
|
|
|
|
|
|
import { ClickHandlerType } from '../Overview';
|
|
|
|
|
import { Button } from '../styles';
|
|
|
|
|
import { IServiceName } from '../types';
|
2023-08-11 12:56:41 +05:30
|
|
|
import { handleNonInQueryRange, onViewTracePopupClick } from '../util';
|
2023-07-18 08:55:01 +05:30
|
|
|
|
|
|
|
|
function ServiceOverview({
|
|
|
|
|
onDragSelect,
|
|
|
|
|
handleGraphClick,
|
|
|
|
|
selectedTraceTags,
|
|
|
|
|
selectedTimeStamp,
|
2023-07-20 12:02:21 +05:30
|
|
|
topLevelOperationsRoute,
|
2023-08-16 12:18:56 +05:30
|
|
|
topLevelOperationsLoading,
|
2023-07-18 08:55:01 +05:30
|
|
|
}: ServiceOverviewProps): JSX.Element {
|
|
|
|
|
const { servicename } = useParams<IServiceName>();
|
|
|
|
|
|
2023-07-20 12:02:21 +05:30
|
|
|
const isSpanMetricEnable = useFeatureFlag(FeatureKeys.USE_SPAN_METRICS)
|
|
|
|
|
?.active;
|
|
|
|
|
|
2023-08-11 12:56:41 +05:30
|
|
|
const { queries } = useResourceAttribute();
|
|
|
|
|
|
|
|
|
|
const tagFilterItems = useMemo(
|
|
|
|
|
() =>
|
|
|
|
|
handleNonInQueryRange(
|
|
|
|
|
resourceAttributesToTagFilterItems(queries, !isSpanMetricEnable),
|
|
|
|
|
) || [],
|
|
|
|
|
[isSpanMetricEnable, queries],
|
|
|
|
|
);
|
|
|
|
|
|
2023-07-18 08:55:01 +05:30
|
|
|
const latencyWidget = useMemo(
|
|
|
|
|
() =>
|
2023-07-28 21:54:36 +05:30
|
|
|
getWidgetQueryBuilder({
|
|
|
|
|
query: {
|
2023-07-18 08:55:01 +05:30
|
|
|
queryType: EQueryType.QUERY_BUILDER,
|
|
|
|
|
promql: [],
|
|
|
|
|
builder: latency({
|
|
|
|
|
servicename,
|
|
|
|
|
tagFilterItems,
|
2023-07-20 12:02:21 +05:30
|
|
|
isSpanMetricEnable,
|
|
|
|
|
topLevelOperationsRoute,
|
2023-07-18 08:55:01 +05:30
|
|
|
}),
|
|
|
|
|
clickhouse_sql: [],
|
|
|
|
|
id: uuid(),
|
|
|
|
|
},
|
2023-07-28 21:54:36 +05:30
|
|
|
title: GraphTitle.LATENCY,
|
|
|
|
|
panelTypes: PANEL_TYPES.TIME_SERIES,
|
|
|
|
|
}),
|
2023-08-11 12:56:41 +05:30
|
|
|
[servicename, isSpanMetricEnable, topLevelOperationsRoute, tagFilterItems],
|
2023-07-18 08:55:01 +05:30
|
|
|
);
|
|
|
|
|
|
2023-07-21 16:17:31 +05:30
|
|
|
const isQueryEnabled = topLevelOperationsRoute.length > 0;
|
|
|
|
|
|
2023-08-16 12:18:56 +05:30
|
|
|
if (topLevelOperationsLoading) {
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
<Spinner height="40vh" tip="Loading..." />
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 08:55:01 +05:30
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Button
|
|
|
|
|
type="default"
|
|
|
|
|
size="small"
|
|
|
|
|
id="Service_button"
|
|
|
|
|
onClick={onViewTracePopupClick({
|
|
|
|
|
servicename,
|
|
|
|
|
selectedTraceTags,
|
|
|
|
|
timestamp: selectedTimeStamp,
|
|
|
|
|
})}
|
|
|
|
|
>
|
|
|
|
|
View Traces
|
|
|
|
|
</Button>
|
|
|
|
|
<Card>
|
|
|
|
|
<GraphContainer>
|
|
|
|
|
<Graph
|
|
|
|
|
name="service_latency"
|
|
|
|
|
onDragSelect={onDragSelect}
|
|
|
|
|
widget={latencyWidget}
|
|
|
|
|
yAxisUnit="ns"
|
|
|
|
|
onClickHandler={handleGraphClick('Service')}
|
2023-07-21 16:17:31 +05:30
|
|
|
isQueryEnabled={isQueryEnabled}
|
2023-07-18 08:55:01 +05:30
|
|
|
/>
|
|
|
|
|
</GraphContainer>
|
|
|
|
|
</Card>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ServiceOverviewProps {
|
|
|
|
|
selectedTimeStamp: number;
|
|
|
|
|
selectedTraceTags: string;
|
|
|
|
|
onDragSelect: (start: number, end: number) => void;
|
|
|
|
|
handleGraphClick: (type: string) => ClickHandlerType;
|
2023-07-20 12:02:21 +05:30
|
|
|
topLevelOperationsRoute: string[];
|
2023-08-16 12:18:56 +05:30
|
|
|
topLevelOperationsLoading: boolean;
|
2023-07-18 08:55:01 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ServiceOverview;
|