mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-01 02:22:00 +08:00
feat: added view logs button for error and latency chart
This commit is contained in:
parent
16738ea7e3
commit
6bc2f9125c
@ -38,6 +38,7 @@ import {
|
|||||||
} from '../MetricsPageQueries/OverviewQueries';
|
} from '../MetricsPageQueries/OverviewQueries';
|
||||||
import { Col, ColApDexContainer, ColErrorContainer, Row } from '../styles';
|
import { Col, ColApDexContainer, ColErrorContainer, Row } from '../styles';
|
||||||
import ApDex from './Overview/ApDex';
|
import ApDex from './Overview/ApDex';
|
||||||
|
import GraphControlsPanel from './Overview/GraphControlsPanel/GraphControlsPanel';
|
||||||
import ServiceOverview from './Overview/ServiceOverview';
|
import ServiceOverview from './Overview/ServiceOverview';
|
||||||
import TopLevelOperation from './Overview/TopLevelOperations';
|
import TopLevelOperation from './Overview/TopLevelOperations';
|
||||||
import TopOperation from './Overview/TopOperation';
|
import TopOperation from './Overview/TopOperation';
|
||||||
@ -48,6 +49,7 @@ import {
|
|||||||
handleNonInQueryRange,
|
handleNonInQueryRange,
|
||||||
onGraphClickHandler,
|
onGraphClickHandler,
|
||||||
onViewTracePopupClick,
|
onViewTracePopupClick,
|
||||||
|
useGetAPMToLogsQueries,
|
||||||
useGetAPMToTracesQueries,
|
useGetAPMToTracesQueries,
|
||||||
} from './util';
|
} from './util';
|
||||||
|
|
||||||
@ -194,33 +196,57 @@ function Application(): JSX.Element {
|
|||||||
[dispatch, pathname, urlQuery],
|
[dispatch, pathname, urlQuery],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onErrorTrackHandler = (
|
const onErrorTrackHandler = useCallback(
|
||||||
timestamp: number,
|
(
|
||||||
apmToTraceQuery: Query,
|
timestamp: number,
|
||||||
): (() => void) => (): void => {
|
apmToTraceQuery: Query,
|
||||||
const currentTime = timestamp;
|
isViewLogsClicked?: boolean,
|
||||||
const tPlusOne = timestamp + 60 * 1000;
|
): (() => void) => (): void => {
|
||||||
|
const currentTime = timestamp;
|
||||||
|
const tPlusOne = timestamp + 60 * 1000;
|
||||||
|
|
||||||
const urlParams = new URLSearchParams(search);
|
const urlParams = new URLSearchParams(search);
|
||||||
urlParams.set(QueryParams.startTime, currentTime.toString());
|
urlParams.set(QueryParams.startTime, currentTime.toString());
|
||||||
urlParams.set(QueryParams.endTime, tPlusOne.toString());
|
urlParams.set(QueryParams.endTime, tPlusOne.toString());
|
||||||
|
|
||||||
const avialableParams = routeConfig[ROUTES.TRACE];
|
const avialableParams = routeConfig[ROUTES.TRACE];
|
||||||
const queryString = getQueryString(avialableParams, urlParams);
|
const queryString = getQueryString(avialableParams, urlParams);
|
||||||
|
|
||||||
const JSONCompositeQuery = encodeURIComponent(
|
const JSONCompositeQuery = encodeURIComponent(
|
||||||
JSON.stringify(apmToTraceQuery),
|
JSON.stringify(apmToTraceQuery),
|
||||||
);
|
);
|
||||||
|
|
||||||
const newTraceExplorerPath = `${
|
const basePath = isViewLogsClicked
|
||||||
ROUTES.TRACES_EXPLORER
|
? ROUTES.LOGS_EXPLORER
|
||||||
}?${urlParams.toString()}&selected={"serviceName":["${servicename}"]}&filterToFetchData=["duration","status","serviceName"]&spanAggregateCurrentPage=1&selectedTags=${selectedTraceTags}&${
|
: ROUTES.TRACES_EXPLORER;
|
||||||
QueryParams.compositeQuery
|
const newPath = `${basePath}?${urlParams.toString()}&selected={"serviceName":["${servicename}"]}&filterToFetchData=["duration","status","serviceName"]&spanAggregateCurrentPage=1&selectedTags=${selectedTraceTags}&${
|
||||||
}=${JSONCompositeQuery}&${queryString.join('&')}`;
|
QueryParams.compositeQuery
|
||||||
|
}=${JSONCompositeQuery}&${queryString.join('&')}`;
|
||||||
|
|
||||||
history.push(newTraceExplorerPath);
|
history.push(newPath);
|
||||||
};
|
},
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const logErrorQuery = useGetAPMToLogsQueries({
|
||||||
|
servicename,
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
id: uuid().slice(0, 8),
|
||||||
|
key: {
|
||||||
|
key: 'hasError',
|
||||||
|
dataType: DataTypes.bool,
|
||||||
|
type: 'tag',
|
||||||
|
isColumn: true,
|
||||||
|
isJSON: false,
|
||||||
|
id: 'hasError--bool--tag--true',
|
||||||
|
},
|
||||||
|
op: '=',
|
||||||
|
value: ['true'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
const errorTrackQuery = useGetAPMToTracesQueries({
|
const errorTrackQuery = useGetAPMToTracesQueries({
|
||||||
servicename,
|
servicename,
|
||||||
filters: [
|
filters: [
|
||||||
@ -304,14 +330,18 @@ function Application(): JSX.Element {
|
|||||||
/>
|
/>
|
||||||
</ColApDexContainer>
|
</ColApDexContainer>
|
||||||
<ColErrorContainer>
|
<ColErrorContainer>
|
||||||
<Button
|
<GraphControlsPanel
|
||||||
type="default"
|
|
||||||
size="small"
|
|
||||||
id="Error_button"
|
id="Error_button"
|
||||||
onClick={onErrorTrackHandler(selectedTimeStamp, errorTrackQuery)}
|
onViewLogsClick={onErrorTrackHandler(
|
||||||
>
|
selectedTimeStamp,
|
||||||
View Traces
|
logErrorQuery,
|
||||||
</Button>
|
true,
|
||||||
|
)}
|
||||||
|
onViewTracesClick={onErrorTrackHandler(
|
||||||
|
selectedTimeStamp,
|
||||||
|
errorTrackQuery,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<TopLevelOperation
|
<TopLevelOperation
|
||||||
handleGraphClick={handleGraphClick}
|
handleGraphClick={handleGraphClick}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
.graph-controls-panel {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 999;
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 110px;
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 5px;
|
||||||
|
background: var(--bg-slate-400);
|
||||||
|
|
||||||
|
.ant-btn-link {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--bg-vanilla-100);
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-btn-link:hover {
|
||||||
|
color: var(--bg-vanilla-100);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
import './GraphControlsPanel.styles.scss';
|
||||||
|
|
||||||
|
import { Color } from '@signozhq/design-tokens';
|
||||||
|
import { Button } from 'antd';
|
||||||
|
import { DraftingCompass, ScrollText } from 'lucide-react';
|
||||||
|
|
||||||
|
interface GraphControlsPanelProps {
|
||||||
|
id: string;
|
||||||
|
onViewLogsClick: () => void;
|
||||||
|
onViewTracesClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function GraphControlsPanel({
|
||||||
|
id,
|
||||||
|
onViewLogsClick,
|
||||||
|
onViewTracesClick,
|
||||||
|
}: GraphControlsPanelProps): JSX.Element {
|
||||||
|
return (
|
||||||
|
<div id={id} className="graph-controls-panel">
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
icon={<DraftingCompass size={14} />}
|
||||||
|
size="small"
|
||||||
|
onClick={onViewTracesClick}
|
||||||
|
style={{ color: Color.BG_VANILLA_100 }}
|
||||||
|
>
|
||||||
|
View traces
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
icon={<ScrollText size={14} />}
|
||||||
|
size="small"
|
||||||
|
onClick={onViewLogsClick}
|
||||||
|
style={{ color: Color.BG_VANILLA_100 }}
|
||||||
|
>
|
||||||
|
View logs
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GraphControlsPanel;
|
@ -19,13 +19,14 @@ import { useParams } from 'react-router-dom';
|
|||||||
import { EQueryType } from 'types/common/dashboard';
|
import { EQueryType } from 'types/common/dashboard';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
import { Button } from '../styles';
|
|
||||||
import { IServiceName } from '../types';
|
import { IServiceName } from '../types';
|
||||||
import {
|
import {
|
||||||
handleNonInQueryRange,
|
handleNonInQueryRange,
|
||||||
onViewTracePopupClick,
|
onViewTracePopupClick,
|
||||||
|
useGetAPMToLogsQueries,
|
||||||
useGetAPMToTracesQueries,
|
useGetAPMToTracesQueries,
|
||||||
} from '../util';
|
} from '../util';
|
||||||
|
import GraphControlsPanel from './GraphControlsPanel/GraphControlsPanel';
|
||||||
|
|
||||||
function ServiceOverview({
|
function ServiceOverview({
|
||||||
onDragSelect,
|
onDragSelect,
|
||||||
@ -75,21 +76,26 @@ function ServiceOverview({
|
|||||||
|
|
||||||
const apmToTraceQuery = useGetAPMToTracesQueries({ servicename });
|
const apmToTraceQuery = useGetAPMToTracesQueries({ servicename });
|
||||||
|
|
||||||
|
const apmToLogQuery = useGetAPMToLogsQueries({ servicename });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button
|
<GraphControlsPanel
|
||||||
type="default"
|
|
||||||
size="small"
|
|
||||||
id="Service_button"
|
id="Service_button"
|
||||||
onClick={onViewTracePopupClick({
|
onViewLogsClick={onViewTracePopupClick({
|
||||||
|
servicename,
|
||||||
|
selectedTraceTags,
|
||||||
|
timestamp: selectedTimeStamp,
|
||||||
|
apmToTraceQuery: apmToLogQuery,
|
||||||
|
isViewLogsClicked: true,
|
||||||
|
})}
|
||||||
|
onViewTracesClick={onViewTracePopupClick({
|
||||||
servicename,
|
servicename,
|
||||||
selectedTraceTags,
|
selectedTraceTags,
|
||||||
timestamp: selectedTimeStamp,
|
timestamp: selectedTimeStamp,
|
||||||
apmToTraceQuery,
|
apmToTraceQuery,
|
||||||
})}
|
})}
|
||||||
>
|
/>
|
||||||
View Traces
|
|
||||||
</Button>
|
|
||||||
<Card data-testid="service_latency">
|
<Card data-testid="service_latency">
|
||||||
<GraphContainer>
|
<GraphContainer>
|
||||||
{topLevelOperationsIsLoading && (
|
{topLevelOperationsIsLoading && (
|
||||||
|
@ -5,6 +5,7 @@ import { routeConfig } from 'container/SideNav/config';
|
|||||||
import { getQueryString } from 'container/SideNav/helper';
|
import { getQueryString } from 'container/SideNav/helper';
|
||||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||||
import history from 'lib/history';
|
import history from 'lib/history';
|
||||||
|
import { prepareQueryWithDefaultTimestamp } from 'pages/LogsExplorer/utils';
|
||||||
import { traceFilterKeys } from 'pages/TracesExplorer/Filter/filterUtils';
|
import { traceFilterKeys } from 'pages/TracesExplorer/Filter/filterUtils';
|
||||||
import { Dispatch, SetStateAction, useMemo } from 'react';
|
import { Dispatch, SetStateAction, useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
@ -31,12 +32,14 @@ interface OnViewTracePopupClickProps {
|
|||||||
selectedTraceTags: string;
|
selectedTraceTags: string;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
apmToTraceQuery: Query;
|
apmToTraceQuery: Query;
|
||||||
|
isViewLogsClicked?: boolean;
|
||||||
}
|
}
|
||||||
export function onViewTracePopupClick({
|
export function onViewTracePopupClick({
|
||||||
selectedTraceTags,
|
selectedTraceTags,
|
||||||
servicename,
|
servicename,
|
||||||
timestamp,
|
timestamp,
|
||||||
apmToTraceQuery,
|
apmToTraceQuery,
|
||||||
|
isViewLogsClicked,
|
||||||
}: OnViewTracePopupClickProps): VoidFunction {
|
}: OnViewTracePopupClickProps): VoidFunction {
|
||||||
return (): void => {
|
return (): void => {
|
||||||
const currentTime = timestamp;
|
const currentTime = timestamp;
|
||||||
@ -53,13 +56,14 @@ export function onViewTracePopupClick({
|
|||||||
JSON.stringify(apmToTraceQuery),
|
JSON.stringify(apmToTraceQuery),
|
||||||
);
|
);
|
||||||
|
|
||||||
const newTraceExplorerPath = `${
|
const basePath = isViewLogsClicked
|
||||||
ROUTES.TRACES_EXPLORER
|
? ROUTES.LOGS_EXPLORER
|
||||||
}?${urlParams.toString()}&selected={"serviceName":["${servicename}"]}&filterToFetchData=["duration","status","serviceName"]&spanAggregateCurrentPage=1&selectedTags=${selectedTraceTags}&${
|
: ROUTES.TRACES_EXPLORER;
|
||||||
|
const newPath = `${basePath}?${urlParams.toString()}&selected={"serviceName":["${servicename}"]}&filterToFetchData=["duration","status","serviceName"]&spanAggregateCurrentPage=1&selectedTags=${selectedTraceTags}&${
|
||||||
QueryParams.compositeQuery
|
QueryParams.compositeQuery
|
||||||
}=${JSONCompositeQuery}&${queryString.join('&')}`;
|
}=${JSONCompositeQuery}&${queryString.join('&')}`;
|
||||||
|
|
||||||
history.push(newTraceExplorerPath);
|
history.push(newPath);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +83,7 @@ export function onGraphClickHandler(
|
|||||||
|
|
||||||
if (xValue) {
|
if (xValue) {
|
||||||
if (buttonElement) {
|
if (buttonElement) {
|
||||||
buttonElement.style.display = 'block';
|
buttonElement.style.display = 'flex';
|
||||||
buttonElement.style.left = `${mouseX}px`;
|
buttonElement.style.left = `${mouseX}px`;
|
||||||
buttonElement.style.top = `${mouseY}px`;
|
buttonElement.style.top = `${mouseY}px`;
|
||||||
setSelectedTimeStamp(xValue);
|
setSelectedTimeStamp(xValue);
|
||||||
@ -106,12 +110,13 @@ export function handleQueryChange(
|
|||||||
attributeKeys: BaseAutocompleteData,
|
attributeKeys: BaseAutocompleteData,
|
||||||
serviceAttribute: string,
|
serviceAttribute: string,
|
||||||
filters?: TagFilterItem[],
|
filters?: TagFilterItem[],
|
||||||
|
logs?: boolean,
|
||||||
): Query {
|
): Query {
|
||||||
const filterItem: TagFilterItem[] = [
|
const filterItem: TagFilterItem[] = [
|
||||||
{
|
{
|
||||||
id: uuid().slice(0, 8),
|
id: uuid().slice(0, 8),
|
||||||
key: attributeKeys,
|
key: attributeKeys,
|
||||||
op: 'in',
|
op: logs ? '=' : 'in',
|
||||||
value: serviceAttribute,
|
value: serviceAttribute,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -130,6 +135,42 @@ export function handleQueryChange(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useGetAPMToLogsQueries({
|
||||||
|
servicename,
|
||||||
|
filters,
|
||||||
|
}: {
|
||||||
|
servicename: string;
|
||||||
|
filters?: TagFilterItem[];
|
||||||
|
}): Query {
|
||||||
|
const finalFilters: TagFilterItem[] = [];
|
||||||
|
const { updateAllQueriesOperators } = useQueryBuilder();
|
||||||
|
let updatedQuery = updateAllQueriesOperators(
|
||||||
|
initialQueriesMap.logs,
|
||||||
|
PANEL_TYPES.LIST,
|
||||||
|
DataSource.LOGS,
|
||||||
|
);
|
||||||
|
const serviceName = {
|
||||||
|
id: 'service.name--string--resource--true',
|
||||||
|
dataType: DataTypes.String,
|
||||||
|
isColumn: true,
|
||||||
|
key: 'service.name',
|
||||||
|
type: 'resource',
|
||||||
|
isJSON: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (filters?.length) {
|
||||||
|
finalFilters.push(...filters);
|
||||||
|
}
|
||||||
|
updatedQuery = prepareQueryWithDefaultTimestamp(updatedQuery);
|
||||||
|
return handleQueryChange(
|
||||||
|
updatedQuery,
|
||||||
|
serviceName,
|
||||||
|
servicename,
|
||||||
|
finalFilters,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function useGetAPMToTracesQueries({
|
export function useGetAPMToTracesQueries({
|
||||||
servicename,
|
servicename,
|
||||||
isExternalCall,
|
isExternalCall,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user