Skip to content

Commit

Permalink
add loading status to trace view and services pages
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <[email protected]>
  • Loading branch information
ps48 committed Jan 31, 2025
1 parent f820854 commit 0d32c2b
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,22 @@ export function ErrorRatePlt(props: {
return (
<>
<EuiPanel style={{ minWidth: 433, minHeight: 308, maxHeight: 560 }}>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="xs">
<PanelTitle title={props.title ? props.title : 'Trace error rate over time'} />
<EuiButtonGroup
options={props.toggleButtons}
idSelected={props.idSelected}
onChange={(id) => props.setIdSelected(id as 'error_rate' | 'throughput')}
buttonSize="s"
color="text"
/>
</EuiFlexGroup>
{props.isErrorRateTrendLoading ? (
<div className="center-parent-div">
<EuiLoadingChart size="l" mono />
<div className="center-loading-div">
<EuiLoadingChart size="l" />
</div>
) : (
<>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="xs">
<PanelTitle title={props.title ? props.title : 'Trace error rate over time'} />
<EuiButtonGroup
options={props.toggleButtons}
idSelected={props.idSelected}
onChange={(id) => props.setIdSelected(id as 'error_rate' | 'throughput')}
buttonSize="s"
color="text"
/>
</EuiFlexGroup>
<EuiHorizontalRule margin="m" />
<ErrorTrendPlt items={props.items} onClick={onClick} isPanel={true} />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiFlexGroup, EuiHorizontalRule, EuiPanel } from '@elastic/eui';
import { EuiFlexGroup, EuiHorizontalRule, EuiLoadingChart, EuiPanel } from '@elastic/eui';
import round from 'lodash/round';
import React, { useMemo } from 'react';
import { Plt } from '../../../../visualizations/plotly/plot';
Expand Down Expand Up @@ -100,14 +100,30 @@ export function LatencyPlt(props: { data: Plotly.Data[]; isPanel?: boolean }) {
);
}

export function LatencyPltPanel(props: { data: Plotly.Data[]; isPanel?: boolean }) {
export function LatencyPltPanel(props: {
data: Plotly.Data[];
isLatencyTrendLoading: boolean;
isPanel?: boolean;
}) {
return (
<EuiPanel style={{ minWidth: 433, minHeight: 308, maxHeight: 560 }}>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="xs">
<PanelTitle title="24hr latency trend" />
</EuiFlexGroup>
<EuiHorizontalRule margin="m" />
{props.data ? <LatencyPlt data={[props.data]} isPanel={true} /> : <NoMatchMessage size="s" />}
{props.isLatencyTrendLoading ? (
<div className="center-loading-div">
<EuiLoadingChart size="l" />
</div>
) : (
<>
<EuiHorizontalRule margin="m" />
{props.data ? (
<LatencyPlt data={[props.data]} isPanel={true} />
) : (
<NoMatchMessage size="s" />
)}
</>
)}
</EuiPanel>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,22 @@ export function ThroughputPlt(props: {
return (
<>
<EuiPanel style={{ minWidth: 433, minHeight: 308, maxHeight: 560 }}>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="xs">
<PanelTitle title={props.title ? props.title : 'Traces over time'} />
<EuiButtonGroup
options={props.toggleButtons}
idSelected={props.idSelected}
onChange={(id: string) => props.setIdSelected(id as 'error_rate' | 'throughput')}
buttonSize="s"
color="text"
/>
</EuiFlexGroup>
{props.isThroughputTrendLoading ? (
<div className="center-parent-div">
<EuiLoadingChart size="l" mono />
<div className="center-loading-div">
<EuiLoadingChart size="l" />
</div>
) : (
<>
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="xs">
<PanelTitle title={props.title ? props.title : 'Traces over time'} />
<EuiButtonGroup
options={props.toggleButtons}
idSelected={props.idSelected}
onChange={(id: string) => props.setIdSelected(id as 'error_rate' | 'throughput')}
buttonSize="s"
color="text"
/>
</EuiFlexGroup>
<EuiHorizontalRule margin="m" />
<ThroughputTrendPlt items={props.items} onClick={onClick} isPanel={true} />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useState, useMemo } from 'react';
import {
EuiDataGrid,
EuiButtonEmpty,
EuiButtonIcon,
EuiDataGrid,
EuiDataGridColumn,
EuiDataGridSorting,
EuiLoadingContent,
EuiOverlayMask,
EuiButtonIcon,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import React, { useMemo, useState } from 'react';
import { NoMatchMessage } from '../helper_functions';

interface FullScreenWrapperProps {
Expand Down Expand Up @@ -71,6 +72,7 @@ interface RenderCustomDataGridParams {
noMatchMessageSize?: string;
defaultHeight?: string;
visibleColumns?: string[];
isTableDataLoading?: boolean;
}

export const RenderCustomDataGrid: React.FC<RenderCustomDataGridParams> = ({
Expand All @@ -85,6 +87,7 @@ export const RenderCustomDataGrid: React.FC<RenderCustomDataGridParams> = ({
noMatchMessageSize = 'xl',
defaultHeight = '500px',
visibleColumns,
isTableDataLoading,
}) => {
const [localVisibleColumns, setLocalVisibleColumns] = useState(
visibleColumns ?? columns.map((col) => col.id)
Expand Down Expand Up @@ -129,7 +132,11 @@ export const RenderCustomDataGrid: React.FC<RenderCustomDataGridParams> = ({
[]
);

return (
return isTableDataLoading ? (
<div>
<EuiLoadingContent lines={4} />
</div>
) : (
<>
<FullScreenWrapper isFullScreen={isFullScreen} onClose={() => setIsFullScreen(false)}>
<div className={isFullScreen ? 'full-wrapper' : 'normal-wrapper'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const ServiceMetrics = ({
serviceName,
}: ServiceMetricsProps) => {
const [trends, setTrends] = useState<ServiceTrends>({});
const [isTrendsDataLoading, setIsTrendsDataLoading] = useState(false);
const { http } = coreRefs;

const serviceFilter = [
Expand All @@ -45,14 +46,15 @@ export const ServiceMetrics = ({
];

const fetchMetrics = async () => {
await handleServiceTrendsRequest(
setIsTrendsDataLoading(true);
handleServiceTrendsRequest(
http,
'1h',
setTrends,
mode,
serviceFilter,
dataSourceMDSId[0].id
);
).finally(() => setIsTrendsDataLoading(false));
};

useEffect(() => {
Expand All @@ -75,6 +77,7 @@ export const ServiceMetrics = ({
}}
setStartTime={setStartTime}
setEndTime={setEndTime}
isThroughputTrendLoading={isTrendsDataLoading}
/>
</EuiFlexItem>
<EuiFlexItem>
Expand All @@ -86,10 +89,15 @@ export const ServiceMetrics = ({
}}
setStartTime={setStartTime}
setEndTime={setEndTime}
isErrorRateTrendLoading={isTrendsDataLoading}
/>
</EuiFlexItem>
<EuiFlexItem>
<LatencyPltPanel data={trends[serviceName]?.latency_trend} isPanel={true} />
<LatencyPltPanel
data={trends[serviceName]?.latency_trend}
isPanel={true}
isLatencyTrendLoading={isTrendsDataLoading}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Loading

0 comments on commit 0d32c2b

Please sign in to comment.