mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 20:16:00 +08:00
feat: added kafka - scenario - 4 (#6370)
* feat: added kafka - scenario - 4 * feat: added error handling and correct api handler for kafka apis
This commit is contained in:
parent
7086470ce2
commit
468f056530
@ -13,7 +13,6 @@ import {
|
|||||||
MessagingQueuesViewTypeOptions,
|
MessagingQueuesViewTypeOptions,
|
||||||
ProducerLatencyOptions,
|
ProducerLatencyOptions,
|
||||||
} from '../MessagingQueuesUtils';
|
} from '../MessagingQueuesUtils';
|
||||||
import { SelectLabelWithComingSoon } from '../MQCommon/MQCommon';
|
|
||||||
import MessagingQueueOverview from '../MQDetails/MessagingQueueOverview';
|
import MessagingQueueOverview from '../MQDetails/MessagingQueueOverview';
|
||||||
import MessagingQueuesDetails from '../MQDetails/MQDetails';
|
import MessagingQueuesDetails from '../MQDetails/MQDetails';
|
||||||
import MessagingQueuesConfigOptions from '../MQGraph/MQConfigOptions';
|
import MessagingQueuesConfigOptions from '../MQGraph/MQConfigOptions';
|
||||||
@ -70,13 +69,8 @@ function MQDetailPage(): JSX.Element {
|
|||||||
value: MessagingQueuesViewType.producerLatency.value,
|
value: MessagingQueuesViewType.producerLatency.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: (
|
label: MessagingQueuesViewType.dropRate.label,
|
||||||
<SelectLabelWithComingSoon
|
value: MessagingQueuesViewType.dropRate.value,
|
||||||
label={MessagingQueuesViewType.consumerLatency.label}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
value: MessagingQueuesViewType.consumerLatency.value,
|
|
||||||
disabled: true,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@ -96,10 +90,12 @@ function MQDetailPage(): JSX.Element {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="messaging-queue-details">
|
<div className="messaging-queue-details">
|
||||||
<MessagingQueuesDetails
|
{selectedView !== MessagingQueuesViewType.dropRate.value && (
|
||||||
selectedView={selectedView}
|
<MessagingQueuesDetails
|
||||||
producerLatencyOption={producerLatencyOption}
|
selectedView={selectedView}
|
||||||
/>
|
producerLatencyOption={producerLatencyOption}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -139,7 +139,7 @@ const checkValidityOfDetailConfigs = (
|
|||||||
return Boolean(configDetails?.topic && configDetails?.service_name);
|
return Boolean(configDetails?.topic && configDetails?.service_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return selectedView === MessagingQueuesViewType.dropRate.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
function MessagingQueuesDetails({
|
function MessagingQueuesDetails({
|
||||||
@ -213,14 +213,14 @@ function MessagingQueuesDetails({
|
|||||||
<MessagingQueuesTable
|
<MessagingQueuesTable
|
||||||
currentTab={currentTab}
|
currentTab={currentTab}
|
||||||
selectedView={selectedView}
|
selectedView={selectedView}
|
||||||
tableApi={serviceConfigDetails[selectedView].tableApi}
|
tableApi={serviceConfigDetails[selectedView]?.tableApi}
|
||||||
validConfigPresent={checkValidityOfDetailConfigs(
|
validConfigPresent={checkValidityOfDetailConfigs(
|
||||||
timelineQueryData,
|
timelineQueryData,
|
||||||
selectedView,
|
selectedView,
|
||||||
currentTab,
|
currentTab,
|
||||||
configDetailQueryData,
|
configDetailQueryData,
|
||||||
)}
|
)}
|
||||||
tableApiPayload={serviceConfigDetails[selectedView].tableApiPayload}
|
tableApiPayload={serviceConfigDetails[selectedView]?.tableApiPayload}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-nested-ternary */
|
||||||
/* eslint-disable react/require-default-props */
|
/* eslint-disable react/require-default-props */
|
||||||
import './MQTables.styles.scss';
|
import './MQTables.styles.scss';
|
||||||
|
|
||||||
@ -169,15 +170,18 @@ function MessagingQueuesTable({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const { mutate: getViewDetails, isLoading } = useMutation(tableApi, {
|
const { mutate: getViewDetails, isLoading, error, isError } = useMutation(
|
||||||
onSuccess: (data) => {
|
tableApi,
|
||||||
if (data.payload) {
|
{
|
||||||
setColumns(getColumns(data?.payload, history));
|
onSuccess: (data) => {
|
||||||
setTableData(getTableData(data?.payload));
|
if (data.payload) {
|
||||||
}
|
setColumns(getColumns(data?.payload, history));
|
||||||
|
setTableData(getTableData(data?.payload));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: handleConsumerDetailsOnError,
|
||||||
},
|
},
|
||||||
onError: handleConsumerDetailsOnError,
|
);
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
@ -230,6 +234,10 @@ function MessagingQueuesTable({
|
|||||||
</Typography.Text>
|
</Typography.Text>
|
||||||
<Skeleton />
|
<Skeleton />
|
||||||
</div>
|
</div>
|
||||||
|
) : isError ? (
|
||||||
|
<div className="no-data-style">
|
||||||
|
<Typography.Text>{error?.message || SOMETHING_WENT_WRONG}</Typography.Text>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{currentTab && (
|
{currentTab && (
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
import axios from 'api';
|
import axios from 'api';
|
||||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
||||||
import { AxiosError } from 'axios';
|
|
||||||
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
|
||||||
import { MessagingQueueServiceDetailType } from 'pages/MessagingQueues/MessagingQueuesUtils';
|
import { MessagingQueueServiceDetailType } from 'pages/MessagingQueues/MessagingQueuesUtils';
|
||||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||||
|
|
||||||
export interface MessagingQueueServicePayload {
|
export interface MessagingQueueServicePayload {
|
||||||
start?: number | string;
|
start?: number | string;
|
||||||
end?: number | string;
|
end?: number | string;
|
||||||
variables: {
|
variables?: {
|
||||||
partition?: string;
|
partition?: string;
|
||||||
topic?: string;
|
topic?: string;
|
||||||
consumer_group?: string;
|
consumer_group?: string;
|
||||||
service_name?: string;
|
service_name?: string;
|
||||||
};
|
};
|
||||||
detailType?: MessagingQueueServiceDetailType | 'producer' | 'consumer';
|
detailType?: MessagingQueueServiceDetailType | 'producer' | 'consumer';
|
||||||
|
evalTime?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MessagingQueuesPayloadProps {
|
export interface MessagingQueuesPayloadProps {
|
||||||
@ -42,21 +40,17 @@ export const getConsumerLagDetails = async (
|
|||||||
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
||||||
> => {
|
> => {
|
||||||
const { detailType, ...restProps } = props;
|
const { detailType, ...restProps } = props;
|
||||||
try {
|
const response = await axios.post(
|
||||||
const response = await axios.post(
|
`/messaging-queues/kafka/consumer-lag/${props.detailType}`,
|
||||||
`/messaging-queues/kafka/consumer-lag/${props.detailType}`,
|
{
|
||||||
{
|
...restProps,
|
||||||
...restProps,
|
},
|
||||||
},
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
error: null,
|
error: null,
|
||||||
message: response.data.status,
|
message: response.data.status,
|
||||||
payload: response.data.data,
|
payload: response.data.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
return ErrorResponseHandler((error as AxiosError) || SOMETHING_WENT_WRONG);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import axios from 'api';
|
||||||
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||||
|
|
||||||
|
import {
|
||||||
|
MessagingQueueServicePayload,
|
||||||
|
MessagingQueuesPayloadProps,
|
||||||
|
} from './getConsumerLagDetails';
|
||||||
|
|
||||||
|
export const getKafkaSpanEval = async (
|
||||||
|
props: Omit<MessagingQueueServicePayload, 'detailType' | 'variables'>,
|
||||||
|
): Promise<
|
||||||
|
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
||||||
|
> => {
|
||||||
|
const { start, end, evalTime } = props;
|
||||||
|
const response = await axios.post(`messaging-queues/kafka/span/evaluation`, {
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
eval_time: evalTime,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
error: null,
|
||||||
|
message: response.data.status,
|
||||||
|
payload: response.data.data,
|
||||||
|
};
|
||||||
|
};
|
@ -1,7 +1,4 @@
|
|||||||
import axios from 'api';
|
import axios from 'api';
|
||||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
||||||
import { AxiosError } from 'axios';
|
|
||||||
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
|
||||||
import { MessagingQueueServiceDetailType } from 'pages/MessagingQueues/MessagingQueuesUtils';
|
import { MessagingQueueServiceDetailType } from 'pages/MessagingQueues/MessagingQueuesUtils';
|
||||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||||
|
|
||||||
@ -22,18 +19,15 @@ export const getPartitionLatencyDetails = async (
|
|||||||
} else {
|
} else {
|
||||||
endpoint = `/messaging-queues/kafka/consumer-lag/producer-details`;
|
endpoint = `/messaging-queues/kafka/consumer-lag/producer-details`;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
const response = await axios.post(endpoint, {
|
|
||||||
...rest,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
const response = await axios.post(endpoint, {
|
||||||
statusCode: 200,
|
...rest,
|
||||||
error: null,
|
});
|
||||||
message: response.data.status,
|
|
||||||
payload: response.data.data,
|
return {
|
||||||
};
|
statusCode: 200,
|
||||||
} catch (error) {
|
error: null,
|
||||||
return ErrorResponseHandler((error as AxiosError) || SOMETHING_WENT_WRONG);
|
message: response.data.status,
|
||||||
}
|
payload: response.data.data,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import axios from 'api';
|
import axios from 'api';
|
||||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
||||||
import { AxiosError } from 'axios';
|
|
||||||
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
|
||||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -14,21 +11,17 @@ export const getPartitionLatencyOverview = async (
|
|||||||
): Promise<
|
): Promise<
|
||||||
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
||||||
> => {
|
> => {
|
||||||
try {
|
const response = await axios.post(
|
||||||
const response = await axios.post(
|
`/messaging-queues/kafka/partition-latency/overview`,
|
||||||
`/messaging-queues/kafka/partition-latency/overview`,
|
{
|
||||||
{
|
...props,
|
||||||
...props,
|
},
|
||||||
},
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
error: null,
|
error: null,
|
||||||
message: response.data.status,
|
message: response.data.status,
|
||||||
payload: response.data.data,
|
payload: response.data.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
return ErrorResponseHandler((error as AxiosError) || SOMETHING_WENT_WRONG);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import axios from 'api';
|
import axios from 'api';
|
||||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
||||||
import { AxiosError } from 'axios';
|
|
||||||
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
|
||||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -16,18 +13,14 @@ export const getTopicThroughputDetails = async (
|
|||||||
> => {
|
> => {
|
||||||
const { detailType, ...rest } = props;
|
const { detailType, ...rest } = props;
|
||||||
const endpoint = `/messaging-queues/kafka/topic-throughput/${detailType}`;
|
const endpoint = `/messaging-queues/kafka/topic-throughput/${detailType}`;
|
||||||
try {
|
const response = await axios.post(endpoint, {
|
||||||
const response = await axios.post(endpoint, {
|
...rest,
|
||||||
...rest,
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
error: null,
|
error: null,
|
||||||
message: response.data.status,
|
message: response.data.status,
|
||||||
payload: response.data.data,
|
payload: response.data.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
return ErrorResponseHandler((error as AxiosError) || SOMETHING_WENT_WRONG);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import axios from 'api';
|
import axios from 'api';
|
||||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
|
||||||
import { AxiosError } from 'axios';
|
|
||||||
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
|
||||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -15,23 +12,18 @@ export const getTopicThroughputOverview = async (
|
|||||||
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
SuccessResponse<MessagingQueuesPayloadProps['payload']> | ErrorResponse
|
||||||
> => {
|
> => {
|
||||||
const { detailType, start, end } = props;
|
const { detailType, start, end } = props;
|
||||||
console.log(detailType);
|
const response = await axios.post(
|
||||||
try {
|
`messaging-queues/kafka/topic-throughput/${detailType}`,
|
||||||
const response = await axios.post(
|
{
|
||||||
`messaging-queues/kafka/topic-throughput/${detailType}`,
|
start,
|
||||||
{
|
end,
|
||||||
start,
|
},
|
||||||
end,
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
error: null,
|
error: null,
|
||||||
message: response.data.status,
|
message: response.data.status,
|
||||||
payload: response.data.data,
|
payload: response.data.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
|
||||||
return ErrorResponseHandler((error as AxiosError) || SOMETHING_WENT_WRONG);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,7 @@ import {
|
|||||||
ProducerLatencyOptions,
|
ProducerLatencyOptions,
|
||||||
} from '../MessagingQueuesUtils';
|
} from '../MessagingQueuesUtils';
|
||||||
import { MessagingQueueServicePayload } from './MQTables/getConsumerLagDetails';
|
import { MessagingQueueServicePayload } from './MQTables/getConsumerLagDetails';
|
||||||
|
import { getKafkaSpanEval } from './MQTables/getKafkaSpanEval';
|
||||||
import { getPartitionLatencyOverview } from './MQTables/getPartitionLatencyOverview';
|
import { getPartitionLatencyOverview } from './MQTables/getPartitionLatencyOverview';
|
||||||
import { getTopicThroughputOverview } from './MQTables/getTopicThroughputOverview';
|
import { getTopicThroughputOverview } from './MQTables/getTopicThroughputOverview';
|
||||||
import MessagingQueuesTable from './MQTables/MQTables';
|
import MessagingQueuesTable from './MQTables/MQTables';
|
||||||
@ -51,6 +52,9 @@ const getTableApi = (selectedView: MessagingQueuesViewTypeOptions): any => {
|
|||||||
if (selectedView === MessagingQueuesViewType.producerLatency.value) {
|
if (selectedView === MessagingQueuesViewType.producerLatency.value) {
|
||||||
return getTopicThroughputOverview;
|
return getTopicThroughputOverview;
|
||||||
}
|
}
|
||||||
|
if (selectedView === MessagingQueuesViewType.dropRate.value) {
|
||||||
|
return getKafkaSpanEval;
|
||||||
|
}
|
||||||
return getPartitionLatencyOverview;
|
return getPartitionLatencyOverview;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -78,6 +82,10 @@ function MessagingQueueOverview({
|
|||||||
? 'producer'
|
? 'producer'
|
||||||
: 'consumer'
|
: 'consumer'
|
||||||
: undefined,
|
: undefined,
|
||||||
|
evalTime:
|
||||||
|
selectedView === MessagingQueuesViewType.dropRate.value
|
||||||
|
? 2363404
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -187,7 +187,7 @@ function MessagingQueues(): JSX.Element {
|
|||||||
</div>
|
</div>
|
||||||
<div className="summary-card coming-soon-card">
|
<div className="summary-card coming-soon-card">
|
||||||
<div className="summary-title">
|
<div className="summary-title">
|
||||||
<p>{MessagingQueuesViewType.consumerLatency.label}</p>
|
<p>{MessagingQueuesViewType.dropRate.label}</p>
|
||||||
<div className="time-value">
|
<div className="time-value">
|
||||||
<Calendar size={14} color={Color.BG_SLATE_200} />
|
<Calendar size={14} color={Color.BG_SLATE_200} />
|
||||||
<p className="time-value">1D</p>
|
<p className="time-value">1D</p>
|
||||||
|
@ -238,9 +238,9 @@ export const MessagingQueuesViewType = {
|
|||||||
label: 'Producer Latency view',
|
label: 'Producer Latency view',
|
||||||
value: MessagingQueuesViewTypeOptions.ProducerLatency,
|
value: MessagingQueuesViewTypeOptions.ProducerLatency,
|
||||||
},
|
},
|
||||||
consumerLatency: {
|
dropRate: {
|
||||||
label: 'Consumer latency view',
|
label: 'Drop Rate',
|
||||||
value: MessagingQueuesViewTypeOptions.ConsumerLatency,
|
value: 'dropRate',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user