mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 06:55:58 +08:00
fix(apm): update the apdex to latest response structure (#7966)
* fix(apm): update the apdex to latest response structure * fix(apm): update the apdex to latest response structure
This commit is contained in:
parent
33506cafce
commit
175e9a4c5e
@ -1,8 +0,0 @@
|
|||||||
import axios from 'api';
|
|
||||||
import { AxiosResponse } from 'axios';
|
|
||||||
import { ApDexPayloadAndSettingsProps } from 'types/api/metrics/getApDex';
|
|
||||||
|
|
||||||
export const getApDexSettings = (
|
|
||||||
servicename: string,
|
|
||||||
): Promise<AxiosResponse<ApDexPayloadAndSettingsProps[]>> =>
|
|
||||||
axios.get(`/settings/apdex?services=${servicename}`);
|
|
26
frontend/src/api/v1/settings/apdex/services/get.ts
Normal file
26
frontend/src/api/v1/settings/apdex/services/get.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import axios from 'api';
|
||||||
|
import { ErrorResponseHandlerV2 } from 'api/ErrorResponseHandlerV2';
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
import { ErrorV2Resp, SuccessResponseV2 } from 'types/api';
|
||||||
|
import {
|
||||||
|
ApDexPayloadAndSettingsProps,
|
||||||
|
PayloadProps,
|
||||||
|
} from 'types/api/metrics/getApDex';
|
||||||
|
|
||||||
|
const getApDexSettings = async (
|
||||||
|
servicename: string,
|
||||||
|
): Promise<SuccessResponseV2<ApDexPayloadAndSettingsProps[]>> => {
|
||||||
|
try {
|
||||||
|
const response = await axios.get<PayloadProps>(
|
||||||
|
`/settings/apdex?services=${servicename}`,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
httpStatusCode: response.status,
|
||||||
|
data: response.data.data,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
ErrorResponseHandlerV2(error as AxiosError<ErrorV2Resp>);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getApDexSettings;
|
@ -1,8 +1,8 @@
|
|||||||
import Spinner from 'components/Spinner';
|
import Spinner from 'components/Spinner';
|
||||||
import { Card, GraphContainer } from 'container/MetricsApplication/styles';
|
import { Card, GraphContainer } from 'container/MetricsApplication/styles';
|
||||||
import { useGetApDexSettings } from 'hooks/apDex/useGetApDexSettings';
|
import { useGetApDexSettings } from 'hooks/apDex/useGetApDexSettings';
|
||||||
import useErrorNotification from 'hooks/useErrorNotification';
|
import { useNotifications } from 'hooks/useNotifications';
|
||||||
import { memo } from 'react';
|
import { memo, useEffect } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { IServiceName } from '../../types';
|
import { IServiceName } from '../../types';
|
||||||
@ -17,11 +17,20 @@ function ApDexApplication({
|
|||||||
}: ApDexApplicationProps): JSX.Element {
|
}: ApDexApplicationProps): JSX.Element {
|
||||||
const { servicename: encodedServiceName } = useParams<IServiceName>();
|
const { servicename: encodedServiceName } = useParams<IServiceName>();
|
||||||
const servicename = decodeURIComponent(encodedServiceName);
|
const servicename = decodeURIComponent(encodedServiceName);
|
||||||
|
const { notifications } = useNotifications();
|
||||||
|
|
||||||
const { data, isLoading, error, isRefetching } = useGetApDexSettings(
|
const { data, isLoading, error, isRefetching } = useGetApDexSettings(
|
||||||
servicename,
|
servicename,
|
||||||
);
|
);
|
||||||
useErrorNotification(error);
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (error) {
|
||||||
|
notifications.error({
|
||||||
|
message: error.getErrorCode(),
|
||||||
|
description: error.getErrorMessage(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [error, notifications]);
|
||||||
|
|
||||||
if (isLoading || isRefetching) {
|
if (isLoading || isRefetching) {
|
||||||
return (
|
return (
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
import { getApDexSettings } from 'api/metrics/ApDex/getApDexSettings';
|
import getApDexSettings from 'api/v1/settings/apdex/services/get';
|
||||||
import { AxiosError, AxiosResponse } from 'axios';
|
|
||||||
import { useQuery, UseQueryResult } from 'react-query';
|
import { useQuery, UseQueryResult } from 'react-query';
|
||||||
|
import { SuccessResponseV2 } from 'types/api';
|
||||||
|
import APIError from 'types/api/error';
|
||||||
import { ApDexPayloadAndSettingsProps } from 'types/api/metrics/getApDex';
|
import { ApDexPayloadAndSettingsProps } from 'types/api/metrics/getApDex';
|
||||||
|
|
||||||
export const useGetApDexSettings = (
|
export const useGetApDexSettings = (
|
||||||
servicename: string,
|
servicename: string,
|
||||||
): UseQueryResult<AxiosResponse<ApDexPayloadAndSettingsProps[]>, AxiosError> =>
|
): UseQueryResult<
|
||||||
useQuery<AxiosResponse<ApDexPayloadAndSettingsProps[]>, AxiosError>({
|
SuccessResponseV2<ApDexPayloadAndSettingsProps[]>,
|
||||||
|
APIError
|
||||||
|
> =>
|
||||||
|
useQuery<SuccessResponseV2<ApDexPayloadAndSettingsProps[]>, APIError>({
|
||||||
queryKey: [{ servicename }],
|
queryKey: [{ servicename }],
|
||||||
queryFn: async () => getApDexSettings(servicename),
|
queryFn: async () => getApDexSettings(servicename),
|
||||||
});
|
});
|
||||||
|
@ -2,8 +2,8 @@ import { SettingOutlined } from '@ant-design/icons';
|
|||||||
import { Popover } from 'antd';
|
import { Popover } from 'antd';
|
||||||
import { IServiceName } from 'container/MetricsApplication/Tabs/types';
|
import { IServiceName } from 'container/MetricsApplication/Tabs/types';
|
||||||
import { useGetApDexSettings } from 'hooks/apDex/useGetApDexSettings';
|
import { useGetApDexSettings } from 'hooks/apDex/useGetApDexSettings';
|
||||||
import useErrorNotification from 'hooks/useErrorNotification';
|
import { useNotifications } from 'hooks/useNotifications';
|
||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { Button } from '../styles';
|
import { Button } from '../styles';
|
||||||
@ -20,7 +20,16 @@ function ApDexApplication(): JSX.Element {
|
|||||||
refetch: refetchGetApDexSetting,
|
refetch: refetchGetApDexSetting,
|
||||||
} = useGetApDexSettings(servicename);
|
} = useGetApDexSettings(servicename);
|
||||||
const [isOpen, setIsOpen] = useState<boolean>(false);
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
||||||
useErrorNotification(error);
|
const { notifications } = useNotifications();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (error) {
|
||||||
|
notifications.error({
|
||||||
|
message: error.getErrorCode(),
|
||||||
|
description: error.getErrorMessage(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [error, notifications]);
|
||||||
|
|
||||||
const handlePopOverClose = (): void => {
|
const handlePopOverClose = (): void => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { AxiosResponse } from 'axios';
|
import { StatusCodes } from 'http-status-codes';
|
||||||
|
import { SuccessResponseV2 } from 'types/api';
|
||||||
|
import { ApDexPayloadAndSettingsProps } from 'types/api/metrics/getApDex';
|
||||||
|
|
||||||
export const axiosResponseThresholdData = {
|
export const axiosResponseThresholdData = {
|
||||||
data: [
|
data: [
|
||||||
@ -6,4 +8,5 @@ export const axiosResponseThresholdData = {
|
|||||||
threshold: 0.5,
|
threshold: 0.5,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
} as AxiosResponse;
|
httpStatusCode: StatusCodes.OK,
|
||||||
|
} as SuccessResponseV2<ApDexPayloadAndSettingsProps[]>;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { AxiosResponse } from 'axios';
|
import { SuccessResponseV2 } from 'types/api';
|
||||||
import { ApDexPayloadAndSettingsProps } from 'types/api/metrics/getApDex';
|
import { ApDexPayloadAndSettingsProps } from 'types/api/metrics/getApDex';
|
||||||
|
|
||||||
export interface ApDexSettingsProps {
|
export interface ApDexSettingsProps {
|
||||||
servicename: string;
|
servicename: string;
|
||||||
handlePopOverClose: () => void;
|
handlePopOverClose: () => void;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
data?: AxiosResponse<ApDexPayloadAndSettingsProps[]>;
|
data?: SuccessResponseV2<ApDexPayloadAndSettingsProps[]>;
|
||||||
refetchGetApDexSetting?: () => void;
|
refetchGetApDexSetting?: () => void;
|
||||||
}
|
}
|
||||||
|
@ -12,3 +12,8 @@ export interface MetricMetaProps {
|
|||||||
delta: boolean;
|
delta: boolean;
|
||||||
le: number[] | null;
|
le: number[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PayloadProps {
|
||||||
|
data: ApDexPayloadAndSettingsProps[];
|
||||||
|
status: string;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user