mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-09-23 09:03:13 +08:00
Merge branch 'issue-92' into issue-103-
This commit is contained in:
commit
8b743f7803
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Select, Button, Space, Form } from "antd";
|
import { Select as DefaultSelect, Button, Space, Form } from "antd";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { withRouter } from "react-router";
|
import { withRouter } from "react-router";
|
||||||
import { RouteComponentProps, useLocation } from "react-router-dom";
|
import { RouteComponentProps, useLocation } from "react-router-dom";
|
||||||
@ -10,18 +10,24 @@ import CustomDateTimeModal from "./CustomDateTimeModal";
|
|||||||
import { GlobalTime, updateTimeInterval } from "../../../store/actions";
|
import { GlobalTime, updateTimeInterval } from "../../../store/actions";
|
||||||
import { StoreState } from "../../../store/reducers";
|
import { StoreState } from "../../../store/reducers";
|
||||||
import FormItem from "antd/lib/form/FormItem";
|
import FormItem from "antd/lib/form/FormItem";
|
||||||
import { DefaultOptions, ServiceMapOptions } from "./config";
|
import {
|
||||||
|
Options,
|
||||||
|
ServiceMapOptions,
|
||||||
|
DefaultOptionsBasedOnRoute,
|
||||||
|
} from "./config";
|
||||||
import { DateTimeRangeType } from "../../../store/actions";
|
import { DateTimeRangeType } from "../../../store/actions";
|
||||||
import { METRICS_PAGE_QUERY_PARAM } from "Src/constants/query";
|
import { METRICS_PAGE_QUERY_PARAM } from "Src/constants/query";
|
||||||
import { LOCAL_STORAGE } from "Src/constants/localStorage";
|
import { LOCAL_STORAGE } from "Src/constants/localStorage";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
const { Option } = Select;
|
const { Option } = DefaultSelect;
|
||||||
|
|
||||||
const DateTimeWrapper = styled.div`
|
const DateTimeWrapper = styled.div`
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
justify-content: flex-end !important;
|
justify-content: flex-end !important;
|
||||||
`;
|
`;
|
||||||
|
const Select = styled(DefaultSelect)`
|
||||||
|
width: 150px;
|
||||||
|
`;
|
||||||
interface DateTimeSelectorProps extends RouteComponentProps<any> {
|
interface DateTimeSelectorProps extends RouteComponentProps<any> {
|
||||||
currentpath?: string;
|
currentpath?: string;
|
||||||
updateTimeInterval: Function;
|
updateTimeInterval: Function;
|
||||||
@ -34,8 +40,12 @@ This components is mounted all the time. Use event listener to track changes.
|
|||||||
const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const options =
|
const options =
|
||||||
location.pathname === ROUTES.SERVICE_MAP ? ServiceMapOptions : DefaultOptions;
|
location.pathname === ROUTES.SERVICE_MAP ? ServiceMapOptions : Options;
|
||||||
const defaultTime = options[0].value;
|
const defaultTime =
|
||||||
|
location.pathname === ROUTES.SERVICE_MAP ||
|
||||||
|
location.pathname === ROUTES.APPLICATION
|
||||||
|
? DefaultOptionsBasedOnRoute[location.pathname]
|
||||||
|
: DefaultOptionsBasedOnRoute.default;
|
||||||
|
|
||||||
const [customDTPickerVisible, setCustomDTPickerVisible] = useState(false);
|
const [customDTPickerVisible, setCustomDTPickerVisible] = useState(false);
|
||||||
const [timeInterval, setTimeInterval] = useState(defaultTime);
|
const [timeInterval, setTimeInterval] = useState(defaultTime);
|
||||||
@ -82,7 +92,7 @@ const _DateTimeSelector = (props: DateTimeSelectorProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateTimeOnQueryParamChange();
|
updateTimeOnQueryParamChange();
|
||||||
if (findIndex(options, (option) => option.value === timeInterval) === -1) {
|
if (findIndex(options, (option) => option.value === timeInterval) === -1) {
|
||||||
setTimeInterval(options[0].value);
|
setTimeInterval(defaultTime);
|
||||||
}
|
}
|
||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
export const DefaultOptions = [
|
import ROUTES from "Src/constants/routes";
|
||||||
{ value: "custom", label: "Custom" },
|
|
||||||
|
export const Options = [
|
||||||
|
{ value: "5min", label: "Last 5 min" },
|
||||||
{ value: "15min", label: "Last 15 min" },
|
{ value: "15min", label: "Last 15 min" },
|
||||||
{ value: "30min", label: "Last 30 min" },
|
{ value: "30min", label: "Last 30 min" },
|
||||||
{ value: "1hr", label: "Last 1 hour" },
|
{ value: "1hr", label: "Last 1 hour" },
|
||||||
{ value: "6hr", label: "Last 6 hour" },
|
{ value: "6hr", label: "Last 6 hour" },
|
||||||
{ value: "1day", label: "Last 1 day" },
|
{ value: "1day", label: "Last 1 day" },
|
||||||
{ value: "1week", label: "Last 1 week" },
|
{ value: "1week", label: "Last 1 week" },
|
||||||
|
{ value: "custom", label: "Custom" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const ServiceMapOptions = [
|
export const ServiceMapOptions = [
|
||||||
{ value: "1min", label: "Last 1 min" },
|
{ value: "1min", label: "Last 1 min" },
|
||||||
{ value: "5min", label: "Last 5 min" },
|
{ value: "5min", label: "Last 5 min" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const DefaultOptionsBasedOnRoute = {
|
||||||
|
[ROUTES.SERVICE_MAP]: ServiceMapOptions[0].value,
|
||||||
|
[ROUTES.APPLICATION]: Options[0].value,
|
||||||
|
default: Options[2].value,
|
||||||
|
};
|
||||||
|
@ -11,6 +11,7 @@ import { Spin } from "antd";
|
|||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { StoreState } from "../../store/reducers";
|
import { StoreState } from "../../store/reducers";
|
||||||
import { getZoomPx, getGraphData } from "./utils";
|
import { getZoomPx, getGraphData } from "./utils";
|
||||||
|
import { getGraphData, getTooltip } from "./utils";
|
||||||
import SelectService from "./SelectService";
|
import SelectService from "./SelectService";
|
||||||
import { ForceGraph2D } from "react-force-graph";
|
import { ForceGraph2D } from "react-force-graph";
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ const ServiceMap = (props: ServiceMapProps) => {
|
|||||||
fgRef.current.zoomToFit(100, 120);
|
fgRef.current.zoomToFit(100, 120);
|
||||||
}}
|
}}
|
||||||
graphData={graphData}
|
graphData={graphData}
|
||||||
nodeLabel="id"
|
nodeLabel={getTooltip}
|
||||||
linkAutoColorBy={(d) => d.target}
|
linkAutoColorBy={(d) => d.target}
|
||||||
linkDirectionalParticles="value"
|
linkDirectionalParticles="value"
|
||||||
linkDirectionalParticleSpeed={(d) => d.value}
|
linkDirectionalParticleSpeed={(d) => d.value}
|
||||||
@ -112,21 +113,7 @@ const ServiceMap = (props: ServiceMapProps) => {
|
|||||||
onNodeClick={(node) => {
|
onNodeClick={(node) => {
|
||||||
const tooltip = document.querySelector(".graph-tooltip");
|
const tooltip = document.querySelector(".graph-tooltip");
|
||||||
if (tooltip && node) {
|
if (tooltip && node) {
|
||||||
tooltip.innerHTML = `<div style="color:#333333;padding:12px;background: white;border-radius: 2px;">
|
tooltip.innerHTML = getTooltip(node);
|
||||||
<div style="font-weight:bold; margin-bottom:16px;">${node.id}</div>
|
|
||||||
<div class="keyval">
|
|
||||||
<div class="key">P99 latency:</div>
|
|
||||||
<div class="val">${node.p99 / 1000000}ms</div>
|
|
||||||
</div>
|
|
||||||
<div class="keyval">
|
|
||||||
<div class="key">Request:</div>
|
|
||||||
<div class="val">${node.callRate}/sec</div>
|
|
||||||
</div>
|
|
||||||
<div class="keyval">
|
|
||||||
<div class="key">Error Rate:</div>
|
|
||||||
<div class="val">${node.errorRate}%</div>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
nodePointerAreaPaint={(node, color, ctx) => {
|
nodePointerAreaPaint={(node, color, ctx) => {
|
||||||
|
@ -83,4 +83,27 @@ export const getZoomPx = (): number => {
|
|||||||
} else if (width > 2500) {
|
} else if (width > 2500) {
|
||||||
return 360;
|
return 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getTooltip = (node: {
|
||||||
|
p99: number;
|
||||||
|
errorRate: number;
|
||||||
|
callRate: number;
|
||||||
|
id: string;
|
||||||
|
}) => {
|
||||||
|
return `<div style="color:#333333;padding:12px;background: white;border-radius: 2px;">
|
||||||
|
<div style="font-weight:bold; margin-bottom:16px;">${node.id}</div>
|
||||||
|
<div class="keyval">
|
||||||
|
<div class="key">P99 latency:</div>
|
||||||
|
<div class="val">${node.p99 / 1000000}ms</div>
|
||||||
|
</div>
|
||||||
|
<div class="keyval">
|
||||||
|
<div class="key">Request:</div>
|
||||||
|
<div class="val">${node.callRate}/sec</div>
|
||||||
|
</div>
|
||||||
|
<div class="keyval">
|
||||||
|
<div class="key">Error Rate:</div>
|
||||||
|
<div class="val">${node.errorRate}%</div>
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user