mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 20:59:02 +08:00
feat: base setup for inspect metrics feature (#7490)
This commit is contained in:
parent
df5767198c
commit
a4ed9e4d47
@ -0,0 +1,16 @@
|
|||||||
|
.inspect-metrics-modal {
|
||||||
|
.inspect-metrics-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
gap: 6px;
|
||||||
|
|
||||||
|
.inspect-metrics-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: default;
|
||||||
|
color: var(--text-vanilla-500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
frontend/src/container/MetricsExplorer/Inspect/Inspect.tsx
Normal file
48
frontend/src/container/MetricsExplorer/Inspect/Inspect.tsx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import './Inspect.styles.scss';
|
||||||
|
|
||||||
|
import * as Sentry from '@sentry/react';
|
||||||
|
import { Color } from '@signozhq/design-tokens';
|
||||||
|
import { Button, Drawer, Typography } from 'antd';
|
||||||
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
|
import { Compass } from 'lucide-react';
|
||||||
|
import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';
|
||||||
|
|
||||||
|
import { InspectProps } from './types';
|
||||||
|
|
||||||
|
function Inspect({ metricName, isOpen, onClose }: InspectProps): JSX.Element {
|
||||||
|
const isDarkMode = useIsDarkMode();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Sentry.ErrorBoundary fallback={<ErrorBoundaryFallback />}>
|
||||||
|
<Drawer
|
||||||
|
width="100%"
|
||||||
|
title={
|
||||||
|
<div className="inspect-metrics-title">
|
||||||
|
<Typography.Text>Metrics Explorer —</Typography.Text>
|
||||||
|
<Button
|
||||||
|
className="inspect-metrics-button"
|
||||||
|
size="small"
|
||||||
|
icon={<Compass size={14} />}
|
||||||
|
disabled
|
||||||
|
>
|
||||||
|
Inspect Metric
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
open={isOpen}
|
||||||
|
onClose={onClose}
|
||||||
|
style={{
|
||||||
|
overscrollBehavior: 'contain',
|
||||||
|
background: isDarkMode ? Color.BG_INK_400 : Color.BG_VANILLA_100,
|
||||||
|
}}
|
||||||
|
className="inspect-metrics-modal"
|
||||||
|
destroyOnClose
|
||||||
|
>
|
||||||
|
<div>Inspect</div>
|
||||||
|
<div>{metricName}</div>
|
||||||
|
</Drawer>
|
||||||
|
</Sentry.ErrorBoundary>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Inspect;
|
@ -0,0 +1 @@
|
|||||||
|
export const INSPECT_FEATURE_FLAG_KEY = 'metrics-explorer-inspect-feature-flag';
|
3
frontend/src/container/MetricsExplorer/Inspect/index.ts
Normal file
3
frontend/src/container/MetricsExplorer/Inspect/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import Inspect from './Inspect';
|
||||||
|
|
||||||
|
export default Inspect;
|
5
frontend/src/container/MetricsExplorer/Inspect/types.ts
Normal file
5
frontend/src/container/MetricsExplorer/Inspect/types.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export type InspectProps = {
|
||||||
|
metricName: string | null;
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
11
frontend/src/container/MetricsExplorer/Inspect/utils.tsx
Normal file
11
frontend/src/container/MetricsExplorer/Inspect/utils.tsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { INSPECT_FEATURE_FLAG_KEY } from './constants';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the inspect feature flag is enabled
|
||||||
|
* returns true if the feature flag is enabled, false otherwise
|
||||||
|
* Show the inspect button in metrics explorer if the feature flag is enabled
|
||||||
|
*/
|
||||||
|
export function isInspectEnabled(): boolean {
|
||||||
|
const featureFlag = localStorage.getItem(INSPECT_FEATURE_FLAG_KEY);
|
||||||
|
return featureFlag === 'true';
|
||||||
|
}
|
@ -20,6 +20,12 @@
|
|||||||
gap: 4px;
|
gap: 4px;
|
||||||
background-color: var(--bg-slate-300);
|
background-color: var(--bg-slate-300);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inspect-metrics-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.metric-details-content {
|
.metric-details-content {
|
||||||
|
@ -2,12 +2,21 @@ import './MetricDetails.styles.scss';
|
|||||||
import '../Summary/Summary.styles.scss';
|
import '../Summary/Summary.styles.scss';
|
||||||
|
|
||||||
import { Color } from '@signozhq/design-tokens';
|
import { Color } from '@signozhq/design-tokens';
|
||||||
import { Divider, Drawer, Empty, Skeleton, Tooltip, Typography } from 'antd';
|
import {
|
||||||
|
Button,
|
||||||
|
Divider,
|
||||||
|
Drawer,
|
||||||
|
Empty,
|
||||||
|
Skeleton,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
} from 'antd';
|
||||||
import { useGetMetricDetails } from 'hooks/metricsExplorer/useGetMetricDetails';
|
import { useGetMetricDetails } from 'hooks/metricsExplorer/useGetMetricDetails';
|
||||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
import { X } from 'lucide-react';
|
import { Compass, X } from 'lucide-react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
|
import { isInspectEnabled } from '../Inspect/utils';
|
||||||
import { formatNumberIntoHumanReadableFormat } from '../Summary/utils';
|
import { formatNumberIntoHumanReadableFormat } from '../Summary/utils';
|
||||||
import AllAttributes from './AllAttributes';
|
import AllAttributes from './AllAttributes';
|
||||||
import DashboardsAndAlertsPopover from './DashboardsAndAlertsPopover';
|
import DashboardsAndAlertsPopover from './DashboardsAndAlertsPopover';
|
||||||
@ -22,6 +31,7 @@ function MetricDetails({
|
|||||||
onClose,
|
onClose,
|
||||||
isOpen,
|
isOpen,
|
||||||
metricName,
|
metricName,
|
||||||
|
openInspectModal,
|
||||||
}: MetricDetailsProps): JSX.Element {
|
}: MetricDetailsProps): JSX.Element {
|
||||||
const isDarkMode = useIsDarkMode();
|
const isDarkMode = useIsDarkMode();
|
||||||
// const { safeNavigate } = useSafeNavigate();
|
// const { safeNavigate } = useSafeNavigate();
|
||||||
@ -43,6 +53,8 @@ function MetricDetails({
|
|||||||
return formatTimestampToReadableDate(metric.lastReceived);
|
return formatTimestampToReadableDate(metric.lastReceived);
|
||||||
}, [metric]);
|
}, [metric]);
|
||||||
|
|
||||||
|
const showInspectFeature = useMemo(() => isInspectEnabled(), []);
|
||||||
|
|
||||||
const isMetricDetailsLoading = isLoading || isFetching;
|
const isMetricDetailsLoading = isLoading || isFetching;
|
||||||
|
|
||||||
const timeSeries = useMemo(() => {
|
const timeSeries = useMemo(() => {
|
||||||
@ -92,6 +104,19 @@ function MetricDetails({
|
|||||||
>
|
>
|
||||||
Open in Explorer
|
Open in Explorer
|
||||||
</Button> */}
|
</Button> */}
|
||||||
|
{/* Show the based on the feature flag. Will remove before releasing the feature */}
|
||||||
|
{showInspectFeature && (
|
||||||
|
<Button
|
||||||
|
className="inspect-metrics-button"
|
||||||
|
aria-label="Inspect Metric"
|
||||||
|
icon={<Compass size={18} />}
|
||||||
|
onClick={(): void => {
|
||||||
|
if (metric?.name) {
|
||||||
|
openInspectModal(metric.name);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
placement="right"
|
placement="right"
|
||||||
|
@ -10,6 +10,7 @@ export interface MetricDetailsProps {
|
|||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
metricName: string | null;
|
metricName: string | null;
|
||||||
isModalTimeSelection: boolean;
|
isModalTimeSelection: boolean;
|
||||||
|
openInspectModal: (metricName: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DashboardsAndAlertsPopoverProps {
|
export interface DashboardsAndAlertsPopoverProps {
|
||||||
|
@ -13,6 +13,7 @@ import { AppState } from 'store/reducers';
|
|||||||
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
import { GlobalReducer } from 'types/reducer/globalTime';
|
||||||
|
|
||||||
|
import InspectModal from '../Inspect';
|
||||||
import MetricDetails from '../MetricDetails';
|
import MetricDetails from '../MetricDetails';
|
||||||
import MetricsSearch from './MetricsSearch';
|
import MetricsSearch from './MetricsSearch';
|
||||||
import MetricsTable from './MetricsTable';
|
import MetricsTable from './MetricsTable';
|
||||||
@ -35,6 +36,7 @@ function Summary(): JSX.Element {
|
|||||||
TreemapViewType.TIMESERIES,
|
TreemapViewType.TIMESERIES,
|
||||||
);
|
);
|
||||||
const [isMetricDetailsOpen, setIsMetricDetailsOpen] = useState(false);
|
const [isMetricDetailsOpen, setIsMetricDetailsOpen] = useState(false);
|
||||||
|
const [isInspectModalOpen, setIsInspectModalOpen] = useState(false);
|
||||||
const [selectedMetricName, setSelectedMetricName] = useState<string | null>(
|
const [selectedMetricName, setSelectedMetricName] = useState<string | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
@ -150,6 +152,17 @@ function Summary(): JSX.Element {
|
|||||||
setIsMetricDetailsOpen(false);
|
setIsMetricDetailsOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openInspectModal = (metricName: string): void => {
|
||||||
|
setSelectedMetricName(metricName);
|
||||||
|
setIsInspectModalOpen(true);
|
||||||
|
setIsMetricDetailsOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeInspectModal = (): void => {
|
||||||
|
setIsInspectModalOpen(false);
|
||||||
|
setSelectedMetricName(null);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sentry.ErrorBoundary fallback={<ErrorBoundaryFallback />}>
|
<Sentry.ErrorBoundary fallback={<ErrorBoundaryFallback />}>
|
||||||
<div className="metrics-explorer-summary-tab">
|
<div className="metrics-explorer-summary-tab">
|
||||||
@ -184,6 +197,14 @@ function Summary(): JSX.Element {
|
|||||||
onClose={closeMetricDetails}
|
onClose={closeMetricDetails}
|
||||||
metricName={selectedMetricName}
|
metricName={selectedMetricName}
|
||||||
isModalTimeSelection={false}
|
isModalTimeSelection={false}
|
||||||
|
openInspectModal={openInspectModal}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isInspectModalOpen && (
|
||||||
|
<InspectModal
|
||||||
|
isOpen={isInspectModalOpen}
|
||||||
|
onClose={closeInspectModal}
|
||||||
|
metricName={selectedMetricName}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Sentry.ErrorBoundary>
|
</Sentry.ErrorBoundary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user