Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

added min-max values check in latency (#158)

Sai Deepesh72f56881940e
diff --git a/frontend/src/modules/Traces/LatencyModalForm.tsx b/frontend/src/modules/Traces/LatencyModalForm.tsx
index 91a00b12e3..b98b9ee2fb 100644
--- a/frontend/src/modules/Traces/LatencyModalForm.tsx
+++ b/frontend/src/modules/Traces/LatencyModalForm.tsx
@@ -1,6 +1,6 @@
import React from "react";
import { Modal, Form, InputNumber, Col, Row } from "antd";
-import { Store } from "antd/lib/form/interface";
+import { NamePath, Store } from "antd/lib/form/interface";
interface LatencyModalFormProps {
onCreate: (values: Store) => void; //Store is defined in antd forms library
@@ -13,13 +13,32 @@ const LatencyModalForm: React.FC<LatencyModalFormProps> = ({
onCancel,
latencyFilterValues,
}) => {
- const [form] = Form.useForm();
+ const [form] = Form.useForm();
+
+ const validateMinValue = ({ getFieldValue }: {getFieldValue: (name: NamePath) => any}) => ({
+ validator(_, value: any) {
+ if (value < getFieldValue('max')) {
+ return Promise.resolve();
+ }
+ return Promise.reject(new Error('Min value should be less than Max value'));
+ },
+ })
+
+ const validateMaxValue = ({ getFieldValue }: {getFieldValue: (name: NamePath) => any}) => ({
+ validator(_, value: any) {
+ if (value > getFieldValue('min')) {
+ return Promise.resolve();
+ }
+ return Promise.reject(new Error('Max value should be greater than Min value'));
+ },
+ })
+
return (
<Modal
visible={true}
title="Chose min and max values of Latency"
okText="Apply"
- cancelText="Cancel"
+ cancelText="Cancel"
onCancel={onCancel}
onOk={() => {
form
@@ -31,7 +50,7 @@ const LatencyModalForm: React.FC<LatencyModalFormProps> = ({
.catch((info) => {
console.log("Validate Failed:", info);
});
- }}
+ }}
>
<Form
form={form}
@@ -44,14 +63,19 @@ const LatencyModalForm: React.FC<LatencyModalFormProps> = ({
<Col span={12}>
<Form.Item
name="min"
- label="Min (in ms)"
+ label="Min (in ms)"
+ rules={[validateMinValue]}
// rules={[{ required: true, message: 'Please input the title of collection!' }]}
>
<InputNumber />
</Form.Item>
</Col>
<Col span={12}>
- <Form.Item name="max" label="Max (in ms)">
+ <Form.Item
+ name="max"
+ label="Max (in ms)"
+ rules = {[validateMaxValue]}
+ >
<InputNumber />
</Form.Item>
</Col>