mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-29 03:30:40 +00:00
Compare commits
12 Commits
perf/uplot
...
chore/qbv5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91b44c7436 | ||
|
|
d417f11d39 | ||
|
|
0582338128 | ||
|
|
1fb97e382e | ||
|
|
a4f5580256 | ||
|
|
f02b506051 | ||
|
|
38f8ee7c0b | ||
|
|
a2495c2539 | ||
|
|
d0a9697144 | ||
|
|
739754037b | ||
|
|
cf102d870b | ||
|
|
3a76a5be73 |
@@ -15,6 +15,8 @@
|
||||
content="frame-src 'self' blob: data:"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="css/uPlot.min.css" />
|
||||
|
||||
<script>
|
||||
// i18n's language detector would pick the browser locale (e.g. `en-US`), which
|
||||
// /public/locales does not ship; pin it to the bundled language instead.
|
||||
|
||||
@@ -22,7 +22,6 @@ import i18n from '../src/ReactI18';
|
||||
// to its loader default and pulls Monaco from cdn.jsdelivr.net, which msw does
|
||||
// not report because the requests look like static assets.
|
||||
import '../src/lib/monaco/loader';
|
||||
import '../src/lib/uPlotStylesheet';
|
||||
|
||||
import '../src/styles.scss';
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
})(document, 'script');
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="css/uPlot.min.css" />
|
||||
<script type="module" src="./src/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
1
frontend/public/css/uPlot.min.css
vendored
Normal file
1
frontend/public/css/uPlot.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";line-height: 1.5;width: min-content;}.u-title {text-align: center;font-size: 18px;font-weight: bold;}.u-wrap {position: relative;user-select: none;}.u-over, .u-under {position: absolute;}.u-under {overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.u-axis {position: absolute;}.u-legend {font-size: 14px;margin: auto;text-align: center;}.u-inline {display: block;}.u-inline * {display: inline-block;}.u-inline tr {margin-right: 16px;}.u-legend th {font-weight: 600;}.u-legend th > * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;/*this has to be !important since we set inline "background" shorthand */background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;}
|
||||
@@ -15,7 +15,7 @@ import { getBasePath } from 'utils/basePath';
|
||||
import { eventEmitter } from 'utils/getEventEmitter';
|
||||
import { getIsNoAuthMode } from 'utils/noAuthMode';
|
||||
|
||||
import apiV1, { apiAlertManager, apiV2, apiV3, apiV4, apiV5 } from './apiV1';
|
||||
import apiV1, { apiAlertManager, apiV2, apiV4, apiV5 } from './apiV1';
|
||||
import { Logout } from './utils';
|
||||
|
||||
const RESPONSE_TIMEOUT_THRESHOLD = 5000; // 5 seconds
|
||||
@@ -193,19 +193,6 @@ ApiV2Instance.interceptors.response.use(
|
||||
ApiV2Instance.interceptors.request.use(interceptorsRequestResponse);
|
||||
ApiV2Instance.interceptors.request.use(interceptorsRequestBasePath);
|
||||
|
||||
// axios V3
|
||||
export const ApiV3Instance = axios.create({
|
||||
baseURL: `${ENVIRONMENT.baseURL}${apiV3}`,
|
||||
});
|
||||
|
||||
ApiV3Instance.interceptors.response.use(
|
||||
interceptorsResponse,
|
||||
interceptorRejected,
|
||||
);
|
||||
ApiV3Instance.interceptors.request.use(interceptorsRequestResponse);
|
||||
ApiV3Instance.interceptors.request.use(interceptorsRequestBasePath);
|
||||
//
|
||||
|
||||
// axios V4
|
||||
export const ApiV4Instance = axios.create({
|
||||
baseURL: `${ENVIRONMENT.baseURL}${apiV4}`,
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { ApiV3Instance, ApiV4Instance } from 'api';
|
||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
||||
import { AxiosError } from 'axios';
|
||||
import { ENTITY_VERSION_V4 } from 'constants/app';
|
||||
import { ErrorResponse, SuccessResponse, Warning } from 'types/api';
|
||||
import {
|
||||
MetricRangePayloadV3,
|
||||
QueryRangePayload,
|
||||
} from 'types/api/metrics/getQueryRange';
|
||||
|
||||
export const getMetricsQueryRange = async (
|
||||
props: QueryRangePayload,
|
||||
version: string,
|
||||
signal: AbortSignal,
|
||||
headers?: Record<string, string>,
|
||||
): Promise<
|
||||
(SuccessResponse<MetricRangePayloadV3> & { warning?: Warning }) | ErrorResponse
|
||||
> => {
|
||||
try {
|
||||
if (version && version === ENTITY_VERSION_V4) {
|
||||
const response = await ApiV4Instance.post('/query_range', props, {
|
||||
signal,
|
||||
});
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: response.data.status,
|
||||
payload: response.data,
|
||||
params: props,
|
||||
};
|
||||
}
|
||||
|
||||
const response = await ApiV3Instance.post('/query_range', props, {
|
||||
signal,
|
||||
headers,
|
||||
});
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: response.data.status,
|
||||
payload: response.data,
|
||||
params: props,
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorResponseHandler(error as AxiosError);
|
||||
}
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
import { ApiV3Instance } from 'api';
|
||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
||||
import { AxiosError, AxiosResponse } from 'axios';
|
||||
import { baseAutoCompleteIdKeysOrder } from 'constants/queryBuilder';
|
||||
import { createIdFromObjectFields } from 'lib/createIdFromObjectFields';
|
||||
import createQueryParams from 'lib/createQueryParams';
|
||||
// ** Helpers
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
// ** Types
|
||||
import { IGetAggregateAttributePayload } from 'types/api/queryBuilder/getAggregatorAttribute';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
IQueryAutocompleteResponse,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
|
||||
export const getAggregateAttribute = async ({
|
||||
aggregateOperator,
|
||||
searchText,
|
||||
dataSource,
|
||||
source,
|
||||
}: IGetAggregateAttributePayload): Promise<
|
||||
SuccessResponse<IQueryAutocompleteResponse> | ErrorResponse
|
||||
> => {
|
||||
try {
|
||||
const response: AxiosResponse<{
|
||||
data: IQueryAutocompleteResponse;
|
||||
}> = await ApiV3Instance.get(
|
||||
`/autocomplete/aggregate_attributes?${createQueryParams({
|
||||
aggregateOperator,
|
||||
searchText,
|
||||
dataSource: source === 'meter' ? 'meter' : dataSource,
|
||||
})}`,
|
||||
);
|
||||
|
||||
const payload: BaseAutocompleteData[] =
|
||||
response.data.data.attributeKeys?.map(({ id: _, ...item }) => ({
|
||||
...item,
|
||||
id: createIdFromObjectFields(item, baseAutoCompleteIdKeysOrder),
|
||||
})) || [];
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: response.statusText,
|
||||
payload: { attributeKeys: payload },
|
||||
};
|
||||
} catch (e) {
|
||||
return ErrorResponseHandler(e as AxiosError);
|
||||
}
|
||||
};
|
||||
@@ -1,50 +0,0 @@
|
||||
import { ApiV3Instance } from 'api';
|
||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
||||
import { AxiosError, AxiosResponse } from 'axios';
|
||||
import { baseAutoCompleteIdKeysOrder } from 'constants/queryBuilder';
|
||||
import { createIdFromObjectFields } from 'lib/createIdFromObjectFields';
|
||||
import createQueryParams from 'lib/createQueryParams';
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
import { IGetAttributeKeysPayload } from 'types/api/queryBuilder/getAttributeKeys';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
IQueryAutocompleteResponse,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
|
||||
export const getAggregateKeys = async ({
|
||||
aggregateOperator,
|
||||
searchText,
|
||||
dataSource,
|
||||
aggregateAttribute,
|
||||
tagType,
|
||||
}: IGetAttributeKeysPayload): Promise<
|
||||
SuccessResponse<IQueryAutocompleteResponse> | ErrorResponse
|
||||
> => {
|
||||
try {
|
||||
const response: AxiosResponse<{
|
||||
data: IQueryAutocompleteResponse;
|
||||
}> = await ApiV3Instance.get(
|
||||
`/autocomplete/attribute_keys?${createQueryParams({
|
||||
aggregateOperator,
|
||||
searchText,
|
||||
dataSource,
|
||||
aggregateAttribute,
|
||||
})}&tagType=${tagType}`,
|
||||
);
|
||||
|
||||
const payload: BaseAutocompleteData[] =
|
||||
response.data.data.attributeKeys?.map(({ id: _, ...item }) => ({
|
||||
...item,
|
||||
id: createIdFromObjectFields(item, baseAutoCompleteIdKeysOrder),
|
||||
})) || [];
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: response.statusText,
|
||||
payload: { attributeKeys: payload },
|
||||
};
|
||||
} catch (e) {
|
||||
return ErrorResponseHandler(e as AxiosError);
|
||||
}
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
import { ApiV3Instance } from 'api';
|
||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
||||
import { AxiosError, AxiosResponse } from 'axios';
|
||||
import { baseAutoCompleteIdKeysOrder } from 'constants/queryBuilder';
|
||||
import { encode } from 'js-base64';
|
||||
import { createIdFromObjectFields } from 'lib/createIdFromObjectFields';
|
||||
import createQueryParams from 'lib/createQueryParams';
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
import {
|
||||
IGetAttributeSuggestionsPayload,
|
||||
IGetAttributeSuggestionsSuccessResponse,
|
||||
} from 'types/api/queryBuilder/getAttributeSuggestions';
|
||||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
|
||||
export const getAttributeSuggestions = async ({
|
||||
searchText,
|
||||
dataSource,
|
||||
filters,
|
||||
}: IGetAttributeSuggestionsPayload): Promise<
|
||||
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
||||
> => {
|
||||
try {
|
||||
let base64EncodedFiltersString;
|
||||
try {
|
||||
// the replace function is to remove the padding at the end of base64 encoded string which is auto added to make it a multiple of 4
|
||||
// why ? because the current working of qs doesn't work well with padding
|
||||
base64EncodedFiltersString = encode(JSON.stringify(filters)).replace(
|
||||
/=+$/,
|
||||
'',
|
||||
);
|
||||
} catch {
|
||||
// default base64 encoded string for empty filters object
|
||||
base64EncodedFiltersString = 'eyJpdGVtcyI6W10sIm9wIjoiQU5EIn0';
|
||||
}
|
||||
const response: AxiosResponse<{
|
||||
data: IGetAttributeSuggestionsSuccessResponse;
|
||||
}> = await ApiV3Instance.get(
|
||||
`/filter_suggestions?${createQueryParams({
|
||||
searchText,
|
||||
dataSource,
|
||||
existingFilter: base64EncodedFiltersString,
|
||||
})}`,
|
||||
);
|
||||
|
||||
const payload: BaseAutocompleteData[] =
|
||||
response.data.data.attributes?.map(({ id: _, ...item }) => ({
|
||||
...item,
|
||||
id: createIdFromObjectFields(item, baseAutoCompleteIdKeysOrder),
|
||||
})) || [];
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: response.statusText,
|
||||
payload: {
|
||||
attributes: payload,
|
||||
example_queries: response.data.data.example_queries,
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
return ErrorResponseHandler(e as AxiosError);
|
||||
}
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
import { ApiV3Instance } from 'api';
|
||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
||||
import { AxiosError } from 'axios';
|
||||
import createQueryParams from 'lib/createQueryParams';
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
import {
|
||||
IAttributeValuesResponse,
|
||||
IGetAttributeValuesPayload,
|
||||
} from 'types/api/queryBuilder/getAttributesValues';
|
||||
|
||||
export const getAttributesValues = async ({
|
||||
aggregateOperator,
|
||||
dataSource,
|
||||
aggregateAttribute,
|
||||
attributeKey,
|
||||
filterAttributeKeyDataType,
|
||||
tagType,
|
||||
searchText,
|
||||
}: IGetAttributeValuesPayload): Promise<
|
||||
SuccessResponse<IAttributeValuesResponse> | ErrorResponse
|
||||
> => {
|
||||
try {
|
||||
const response = await ApiV3Instance.get(
|
||||
`/autocomplete/attribute_values?${createQueryParams({
|
||||
aggregateOperator,
|
||||
dataSource,
|
||||
aggregateAttribute,
|
||||
attributeKey,
|
||||
searchText,
|
||||
})}&filterAttributeKeyDataType=${filterAttributeKeyDataType}&tagType=${tagType}`,
|
||||
);
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: response.data.status,
|
||||
payload: response.data.data,
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorResponseHandler(error as AxiosError);
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
import { ApiV5Instance } from 'api';
|
||||
import { ErrorResponseHandlerV2 } from 'api/ErrorResponseHandlerV2';
|
||||
import { AxiosError } from 'axios';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { ErrorV2Resp, SuccessResponseV2 } from 'types/api';
|
||||
import {
|
||||
MetricRangePayloadV5,
|
||||
@@ -17,24 +16,10 @@ import {
|
||||
*/
|
||||
export const getQueryRangeV5 = async (
|
||||
props: QueryRangePayloadV5,
|
||||
version: string,
|
||||
signal?: AbortSignal,
|
||||
headers?: Record<string, string>,
|
||||
): Promise<SuccessResponseV2<MetricRangePayloadV5>> => {
|
||||
try {
|
||||
if (version && version === ENTITY_VERSION_V5) {
|
||||
const response = await ApiV5Instance.post('/query_range', props, {
|
||||
signal,
|
||||
headers,
|
||||
});
|
||||
|
||||
return {
|
||||
httpStatusCode: response.status,
|
||||
data: response.data,
|
||||
};
|
||||
}
|
||||
|
||||
// Default V5 behavior
|
||||
const response = await ApiV5Instance.post('/query_range', props, {
|
||||
signal,
|
||||
headers,
|
||||
@@ -42,7 +27,7 @@ export const getQueryRangeV5 = async (
|
||||
|
||||
return {
|
||||
httpStatusCode: response.status,
|
||||
data: response.data.data,
|
||||
data: response.data,
|
||||
};
|
||||
} catch (error) {
|
||||
ErrorResponseHandlerV2(error as AxiosError<ErrorV2Resp>);
|
||||
|
||||
@@ -7,7 +7,6 @@ import { useAppLocation } from 'lib/router/useAppLocation';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { ViewMenuAction } from 'container/WidgetCard/config';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import GridCard from 'container/WidgetCard/Card';
|
||||
import { Card } from 'container/WidgetCard/styles';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
@@ -179,7 +178,6 @@ function CeleryTaskBar({
|
||||
{barState === CeleryTaskState.All && (
|
||||
<GridCard
|
||||
widget={celeryAllStateFilteredData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
isQueryEnabled={queryEnabled}
|
||||
@@ -201,7 +199,6 @@ function CeleryTaskBar({
|
||||
{barState === CeleryTaskState.Failed && (
|
||||
<GridCard
|
||||
widget={celeryFailedStateFilteredData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
isQueryEnabled={queryEnabled}
|
||||
@@ -222,7 +219,6 @@ function CeleryTaskBar({
|
||||
{barState === CeleryTaskState.Retry && (
|
||||
<GridCard
|
||||
widget={celeryRetryStateFilteredData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
isQueryEnabled={queryEnabled}
|
||||
@@ -243,7 +239,6 @@ function CeleryTaskBar({
|
||||
{barState === CeleryTaskState.Successful && (
|
||||
<GridCard
|
||||
widget={celerySuccessStateFilteredData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
isQueryEnabled={queryEnabled}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { navigate } from 'lib/router/navigation';
|
||||
import { useAppLocation } from 'lib/router/useAppLocation';
|
||||
import { QueryParams } from 'constants/query';
|
||||
@@ -137,7 +136,6 @@ function CeleryTaskGraph({
|
||||
isQueryEnabled={queryEnabled}
|
||||
openTracesButton={openTracesButton}
|
||||
onOpenTraceBtnClick={onOpenTraceBtnClick}
|
||||
version={ENTITY_VERSION_V5}
|
||||
customErrorMessage={customErrorMessage}
|
||||
start={start}
|
||||
end={end}
|
||||
|
||||
@@ -9,7 +9,6 @@ import logEvent from 'api/common/logEvent';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { ViewMenuAction } from 'container/WidgetCard/config';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import GridCard from 'container/WidgetCard/Card';
|
||||
import { Card } from 'container/WidgetCard/styles';
|
||||
import { Button } from 'container/MetricsApplication/Tabs/styles';
|
||||
@@ -202,7 +201,6 @@ function CeleryTaskLatencyGraph({
|
||||
</Button>
|
||||
<GridCard
|
||||
widget={updatedWidgetData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
onClickHandler={onGraphClick('Celery_p99_latency')}
|
||||
@@ -224,7 +222,6 @@ function CeleryTaskLatencyGraph({
|
||||
</Button>
|
||||
<GridCard
|
||||
widget={updatedWidgetData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
onClickHandler={onGraphClick('Celery_p95_latency')}
|
||||
@@ -245,7 +242,6 @@ function CeleryTaskLatencyGraph({
|
||||
</Button>
|
||||
<GridCard
|
||||
widget={updatedWidgetData}
|
||||
version={ENTITY_VERSION_V5}
|
||||
headerMenuList={[...ViewMenuAction]}
|
||||
onDragSelect={onDragSelect}
|
||||
onClickHandler={onGraphClick('Celery_p90_latency')}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useCallback } from 'react';
|
||||
import { useQueries } from 'react-query';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useSelector } from 'react-redux';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { GetMetricQueryRange } from 'lib/dashboard/getQueryResults';
|
||||
import {
|
||||
@@ -42,9 +41,9 @@ export const useGetValueFromWidget = (
|
||||
|
||||
const queries = useQueries(
|
||||
queryPayloads().map((payload) => ({
|
||||
queryKey: [...queryKey, payload, ENTITY_VERSION_V5],
|
||||
queryKey: [...queryKey, payload],
|
||||
queryFn: (): Promise<SuccessResponse<MetricRangePayloadProps>> =>
|
||||
GetMetricQueryRange(payload, ENTITY_VERSION_V5),
|
||||
GetMetricQueryRange(payload),
|
||||
enabled: !!payload,
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,6 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
isRawQuery = false,
|
||||
showOnlyWhereClause = false,
|
||||
showTraceOperator = false,
|
||||
version,
|
||||
onSignalSourceChange,
|
||||
signalSourceChangeEnabled = false,
|
||||
savePreviousQuery = false,
|
||||
@@ -235,7 +234,6 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
isMultiQueryAllowed={isMultiQueryAllowed}
|
||||
showTraceOperator={canShowTraceOperator}
|
||||
hasTraceOperator={hasTraceOperator}
|
||||
version={version}
|
||||
isAvailableToDisable={false}
|
||||
queryVariant={config?.queryVariant || 'dropdown'}
|
||||
showOnlyWhereClause={showOnlyWhereClause}
|
||||
@@ -255,7 +253,6 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
query={query}
|
||||
fieldsConfig={fieldsConfig}
|
||||
allowedDataSources={queryDataSources}
|
||||
version={version}
|
||||
isMultiQueryAllowed={isMultiQueryAllowed}
|
||||
isAvailableToDisable={false}
|
||||
showTraceOperator={canShowTraceOperator}
|
||||
|
||||
@@ -23,13 +23,11 @@ import './MetricsAggregateSection.styles.scss';
|
||||
const MetricsAggregateSection = memo(function MetricsAggregateSection({
|
||||
query,
|
||||
index,
|
||||
version,
|
||||
panelType,
|
||||
fieldsConfig,
|
||||
}: {
|
||||
query: IBuilderQuery;
|
||||
index: number;
|
||||
version: string;
|
||||
panelType: PANEL_TYPES | null;
|
||||
fieldsConfig?: QueryBuilderFieldsConfig;
|
||||
}): JSX.Element {
|
||||
@@ -46,7 +44,6 @@ const MetricsAggregateSection = memo(function MetricsAggregateSection({
|
||||
} = useQueryOperations({
|
||||
index,
|
||||
query,
|
||||
entityVersion: version,
|
||||
});
|
||||
|
||||
// this function is only relevant for metrics and now operators are part of aggregations
|
||||
|
||||
@@ -29,7 +29,6 @@ export const SOURCE_OPTIONS: SelectOption<string, string>[] = [
|
||||
export const MetricsSelect = memo(function MetricsSelect({
|
||||
query,
|
||||
index,
|
||||
version,
|
||||
signalSource,
|
||||
onSignalSourceChange,
|
||||
signalSourceChangeEnabled = false,
|
||||
@@ -37,7 +36,6 @@ export const MetricsSelect = memo(function MetricsSelect({
|
||||
}: {
|
||||
query: IBuilderQuery;
|
||||
index: number;
|
||||
version: string;
|
||||
signalSource: 'meter' | '';
|
||||
onSignalSourceChange: (value: string) => void;
|
||||
signalSourceChangeEnabled: boolean;
|
||||
@@ -46,7 +44,6 @@ export const MetricsSelect = memo(function MetricsSelect({
|
||||
const { handleChangeAggregatorAttribute } = useQueryOperations({
|
||||
index,
|
||||
query,
|
||||
entityVersion: version,
|
||||
});
|
||||
|
||||
const { updateAllQueriesOperators, handleSetQueryData, panelType } =
|
||||
|
||||
@@ -53,7 +53,6 @@ import './QueryAddOns.styles.scss';
|
||||
|
||||
function QueryAddOns({
|
||||
query,
|
||||
version,
|
||||
isRawQuery,
|
||||
showReduceTo,
|
||||
panelType,
|
||||
@@ -62,7 +61,6 @@ function QueryAddOns({
|
||||
isForTraceOperator = false,
|
||||
}: {
|
||||
query: IBuilderQuery;
|
||||
version: string;
|
||||
isRawQuery: boolean;
|
||||
showReduceTo: boolean;
|
||||
panelType: PANEL_TYPES | null;
|
||||
@@ -78,7 +76,6 @@ function QueryAddOns({
|
||||
const { handleChangeQueryData } = useQueryOperations({
|
||||
index,
|
||||
query,
|
||||
entityVersion: '',
|
||||
isForTraceOperator,
|
||||
});
|
||||
|
||||
@@ -433,11 +430,9 @@ function QueryAddOns({
|
||||
</Tooltip>
|
||||
<div className="input">
|
||||
<OrderByFilter
|
||||
entityVersion={version}
|
||||
query={query}
|
||||
onChange={handleChangeOrderByKeys}
|
||||
isRawQuery={isRawQuery}
|
||||
isNewQueryV2
|
||||
panelType={panelType ?? undefined}
|
||||
placeholder={placeholderOf(QueryBuilderField.OrderBy)}
|
||||
/>
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from 'react';
|
||||
import { Dropdown, type DropdownItemType } from '@signozhq/ui/dropdown';
|
||||
import cx from 'classnames';
|
||||
import { ENTITY_VERSION_V4, ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import QBEntityOptions from 'container/QueryBuilder/components/QBEntityOptions/QBEntityOptions';
|
||||
import { QueryProps } from 'container/QueryBuilder/type';
|
||||
import SpanScopeSelector from 'container/QueryBuilder/filters/QueryBuilderSearchV2/SpanScopeSelector';
|
||||
@@ -42,7 +41,6 @@ export const QueryV2 = forwardRef(function QueryV2(
|
||||
isRawQuery = false,
|
||||
showTraceOperator = false,
|
||||
hasTraceOperator = false,
|
||||
version,
|
||||
showOnlyWhereClause = false,
|
||||
signalSource = '',
|
||||
isMultiQueryAllowed = false,
|
||||
@@ -77,7 +75,6 @@ export const QueryV2 = forwardRef(function QueryV2(
|
||||
index,
|
||||
query,
|
||||
isRawQuery,
|
||||
entityVersion: version,
|
||||
savePreviousQuery,
|
||||
});
|
||||
|
||||
@@ -193,11 +190,9 @@ export const QueryV2 = forwardRef(function QueryV2(
|
||||
isMetricsDataSource={dataSource === DataSource.METRICS}
|
||||
showFunctions={
|
||||
!functions.hidden &&
|
||||
((version && version === ENTITY_VERSION_V4) ||
|
||||
query.dataSource === DataSource.LOGS ||
|
||||
(query.dataSource === DataSource.LOGS ||
|
||||
query.dataSource === DataSource.METRICS ||
|
||||
hasQueryFunctions ||
|
||||
false)
|
||||
hasQueryFunctions)
|
||||
}
|
||||
areFunctionsDisabled={functions.disabled}
|
||||
functionsDisabledReason={functions.reason}
|
||||
@@ -265,7 +260,6 @@ export const QueryV2 = forwardRef(function QueryV2(
|
||||
<MetricsSelect
|
||||
query={query}
|
||||
index={index}
|
||||
version={ENTITY_VERSION_V5}
|
||||
signalSource={signalSource as 'meter' | ''}
|
||||
onSignalSourceChange={onSignalSourceChange}
|
||||
signalSourceChangeEnabled={signalSourceChangeEnabled}
|
||||
@@ -317,7 +311,6 @@ export const QueryV2 = forwardRef(function QueryV2(
|
||||
query={query}
|
||||
index={index}
|
||||
key={`metrics-aggregate-section-${query.queryName}-${query.dataSource}-${signalSource}`}
|
||||
version="v4"
|
||||
fieldsConfig={fieldsConfig}
|
||||
/>
|
||||
)}
|
||||
@@ -327,7 +320,6 @@ export const QueryV2 = forwardRef(function QueryV2(
|
||||
<QueryAddOns
|
||||
index={index}
|
||||
query={query}
|
||||
version="v3"
|
||||
isRawQuery={isRawQuery}
|
||||
showReduceTo={showReduceTo}
|
||||
panelType={panelType}
|
||||
|
||||
@@ -31,7 +31,6 @@ export default function TraceOperator({
|
||||
const { handleChangeQueryData } = useQueryOperations({
|
||||
index: 0,
|
||||
query: traceOperator,
|
||||
entityVersion: '',
|
||||
isForTraceOperator: true,
|
||||
});
|
||||
|
||||
@@ -116,7 +115,6 @@ export default function TraceOperator({
|
||||
<QueryAddOns
|
||||
index={0}
|
||||
query={traceOperator}
|
||||
version="v3"
|
||||
isForTraceOperator
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
|
||||
@@ -177,7 +177,6 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
<QueryV2
|
||||
index={0}
|
||||
query={queryA}
|
||||
version="v4"
|
||||
isAvailableToDisable={false}
|
||||
isMultiQueryAllowed
|
||||
queriesCount={queriesCount}
|
||||
@@ -190,7 +189,7 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
};
|
||||
|
||||
it('renders limit input when dataSource is logs', () => {
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} version="v4" />);
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} />);
|
||||
|
||||
// Ensure the Limit add-on input is present and is of type number
|
||||
const limitInput = screen.getByPlaceholderText(
|
||||
@@ -204,7 +203,7 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
|
||||
it('Cmd+Enter on the limit input triggers handleRunQuery via container handler', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} version="v4" />);
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} />);
|
||||
|
||||
screen.getByTestId('input-Limit-field').focus();
|
||||
await user.keyboard('{Meta>}{Enter}{/Meta}');
|
||||
@@ -214,7 +213,7 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
|
||||
it('Cmd+Enter on the legend input triggers handleRunQuery via container handler', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} version="v4" />);
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} />);
|
||||
|
||||
screen.getByPlaceholderText('Write legend format').focus();
|
||||
await user.keyboard('{Meta>}{Enter}{/Meta}');
|
||||
@@ -224,7 +223,7 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
|
||||
it('Cmd+Enter in the where clause editor triggers handleRunQuery via container handler', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} version="v4" />);
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} />);
|
||||
|
||||
const editorWrapper = await screen.findByTestId('query-where-clause-editor');
|
||||
within(editorWrapper).getByRole('textbox').focus();
|
||||
@@ -249,7 +248,7 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} version="v4" />),
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} />),
|
||||
).not.toThrow();
|
||||
|
||||
// query list still renders from queryData, formulas block is skipped
|
||||
@@ -342,7 +341,7 @@ describe('QueryBuilderV2 + QueryV2 - base render', () => {
|
||||
},
|
||||
});
|
||||
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} version="v4" />);
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} />);
|
||||
|
||||
const fxButton = screen.getByTestId('query-functions-fx-btn');
|
||||
expect(fxButton).toBeInTheDocument();
|
||||
|
||||
@@ -103,7 +103,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo
|
||||
panelType={PANEL_TYPES.VALUE}
|
||||
@@ -127,7 +126,6 @@ describe('QueryAddOns', () => {
|
||||
dataSource: DataSource.METRICS,
|
||||
groupBy: ['service.name'],
|
||||
})}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -143,7 +141,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.LIST}
|
||||
@@ -159,7 +156,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery({ limit: 5 })}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -193,7 +189,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -215,7 +210,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -237,7 +231,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TOP_LIST}
|
||||
@@ -311,7 +304,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={query}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -332,7 +324,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -348,7 +339,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery({ reduceTo: ReduceOperators.SUM })}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -371,7 +361,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={query}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -423,7 +412,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={query}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -447,7 +435,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery()}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -474,7 +461,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={query}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
@@ -496,7 +482,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery({ dataSource: DataSource.METRICS, ...overrides })}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.HEATMAP}
|
||||
@@ -518,7 +503,6 @@ describe('QueryAddOns', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery({ dataSource: DataSource.METRICS })}
|
||||
version="v5"
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
|
||||
@@ -42,7 +42,6 @@ jest.mock(
|
||||
},
|
||||
);
|
||||
jest.mock('container/QueryBuilder/filters', () => ({
|
||||
AggregatorFilter: (): JSX.Element => <div />,
|
||||
MetricNameSelector: (): JSX.Element => <div />,
|
||||
}));
|
||||
// Mock hooks
|
||||
@@ -150,7 +149,6 @@ describe('MetricsSelect - signal source switching (standalone)', () => {
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
panelType={PANEL_TYPES.TABLE}
|
||||
version="v5"
|
||||
signalSourceChangeEnabled
|
||||
savePreviousQuery
|
||||
/>,
|
||||
@@ -185,11 +183,7 @@ describe('MetricsSelect - signal source switching (standalone)', () => {
|
||||
const user = userEvent.setup();
|
||||
// render WITHOUT savePreviousQuery enabled
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
panelType={PANEL_TYPES.TABLE}
|
||||
version="v5"
|
||||
signalSourceChangeEnabled
|
||||
/>,
|
||||
<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} signalSourceChangeEnabled />,
|
||||
);
|
||||
|
||||
// open Source and choose Meter
|
||||
@@ -307,7 +301,6 @@ describe('DataSource change - Logs to Traces', () => {
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
panelType={PANEL_TYPES.TABLE}
|
||||
version="v5"
|
||||
signalSourceChangeEnabled
|
||||
savePreviousQuery
|
||||
/>,
|
||||
@@ -333,11 +326,7 @@ describe('DataSource change - Logs to Traces', () => {
|
||||
const user = userEvent.setup();
|
||||
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
panelType={PANEL_TYPES.TABLE}
|
||||
version="v5"
|
||||
signalSourceChangeEnabled
|
||||
/>,
|
||||
<QueryBuilderV2 panelType={PANEL_TYPES.TABLE} signalSourceChangeEnabled />,
|
||||
);
|
||||
|
||||
const logsTrigger = within(
|
||||
|
||||
@@ -21,22 +21,18 @@ jest.mock('../QueryV2/QueryV2', () => ({
|
||||
jest.mock('../QueryV2/QueryFooter/QueryFooter', () => (): null => null);
|
||||
|
||||
function renderWith(currentQuery: Query): void {
|
||||
render(
|
||||
<QueryBuilderV2 panelType={PANEL_TYPES.TIME_SERIES} version="v3" />,
|
||||
undefined,
|
||||
{
|
||||
queryBuilderOverrides: {
|
||||
currentQuery,
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
initialDataSource: null,
|
||||
handleSetConfig: jest.fn(),
|
||||
addNewBuilderQuery: jest.fn(),
|
||||
addNewFormula: jest.fn(),
|
||||
addTraceOperator: jest.fn(),
|
||||
handleRunQuery: jest.fn(),
|
||||
},
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.TIME_SERIES} />, undefined, {
|
||||
queryBuilderOverrides: {
|
||||
currentQuery,
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
initialDataSource: null,
|
||||
handleSetConfig: jest.fn(),
|
||||
addNewBuilderQuery: jest.fn(),
|
||||
addNewFormula: jest.fn(),
|
||||
addTraceOperator: jest.fn(),
|
||||
handleRunQuery: jest.fn(),
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
const builderWithQuery = (
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('QueryBuilderV2 provider config sync', () => {
|
||||
it('leaves the data source unset for a bar panel without a static config', () => {
|
||||
const handleSetConfig = mockContext({});
|
||||
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.BAR} version="v3" />);
|
||||
render(<QueryBuilderV2 panelType={PANEL_TYPES.BAR} />);
|
||||
|
||||
expect(handleSetConfig).toHaveBeenCalledWith(PANEL_TYPES.BAR, null);
|
||||
});
|
||||
@@ -61,7 +61,6 @@ describe('QueryBuilderV2 provider config sync', () => {
|
||||
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
version="v3"
|
||||
panelType={PANEL_TYPES.BAR}
|
||||
config={{ initialDataSource: DataSource.LOGS, queryVariant: 'static' }}
|
||||
/>,
|
||||
@@ -78,7 +77,6 @@ describe('QueryBuilderV2 provider config sync', () => {
|
||||
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
version="v3"
|
||||
panelType={PANEL_TYPES.BAR}
|
||||
config={{ initialDataSource: DataSource.TRACES, queryVariant: 'static' }}
|
||||
/>,
|
||||
@@ -98,7 +96,6 @@ describe('QueryBuilderV2 provider config sync', () => {
|
||||
|
||||
render(
|
||||
<QueryBuilderV2
|
||||
version="v3"
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
config={{ initialDataSource: DataSource.TRACES, queryVariant: 'static' }}
|
||||
/>,
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { negateOperator, OPERATORS } from 'constants/antlrQueryConstants';
|
||||
import { initialQueryBuilderFormValuesMap } from 'constants/queryBuilder';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
DataTypes,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { Query, TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
import { TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, ReduceOperators } from 'types/common/queryBuilder';
|
||||
import { extractQueryPairs } from 'utils/queryContextUtils';
|
||||
|
||||
import {
|
||||
adjustQueryForV5,
|
||||
convertAggregationToExpression,
|
||||
convertExpressionToFilters,
|
||||
convertFiltersToExpression,
|
||||
@@ -1687,31 +1684,3 @@ describe('formatValueForExpression', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('adjustQueryForV5', () => {
|
||||
it('adjusts the AI builder slot for AI query builder queries', () => {
|
||||
const emptyBuilder = {
|
||||
queryData: [],
|
||||
queryFormulas: [],
|
||||
queryTraceOperator: [],
|
||||
};
|
||||
const query: Query = {
|
||||
id: 'q',
|
||||
queryType: EQueryType.AI_QUERY_BUILDER,
|
||||
promql: [],
|
||||
clickhouse_sql: [],
|
||||
builder: emptyBuilder,
|
||||
builder_ai_query: {
|
||||
...emptyBuilder,
|
||||
queryData: [initialQueryBuilderFormValuesMap.logs],
|
||||
},
|
||||
};
|
||||
|
||||
const result = adjustQueryForV5(query);
|
||||
|
||||
expect(result.builder).toBe(emptyBuilder);
|
||||
expect(result.builder_ai_query?.queryData[0]).not.toHaveProperty(
|
||||
'aggregateOperator',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -164,7 +164,6 @@ export const appendToAggregation = (
|
||||
|
||||
export const DEFAULT_ARGS: Partial<QueryBuilderProps> = {
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
version: 'v3',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,11 +9,6 @@ import {
|
||||
QUERY_BUILDER_FUNCTIONS,
|
||||
} from 'constants/antlrQueryConstants';
|
||||
import { getOperatorValue } from 'container/QueryBuilder/filters/QueryBuilderSearchV2/utils';
|
||||
import {
|
||||
getActiveBuilder,
|
||||
getBuilderSlotKeyForQueryType,
|
||||
isBuilderQueryType,
|
||||
} from 'lib/query/builderSlot';
|
||||
import FilterQueryLexer from 'parser/FilterQueryLexer';
|
||||
import FilterQueryParser, {
|
||||
AndExpressionContext,
|
||||
@@ -29,7 +24,6 @@ import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteRe
|
||||
import {
|
||||
Having,
|
||||
IBuilderQuery,
|
||||
Query,
|
||||
TagFilter,
|
||||
TagFilterItem,
|
||||
} from 'types/api/queryBuilder/queryBuilderData';
|
||||
@@ -1032,57 +1026,3 @@ export function getQueryLabelWithAggregation(
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
export const adjustQueryForV5 = (currentQuery: Query): Query => {
|
||||
if (isBuilderQueryType(currentQuery.queryType)) {
|
||||
const activeBuilder = getActiveBuilder(currentQuery);
|
||||
const newQueryData = activeBuilder.queryData.map((query) => {
|
||||
const aggregations = query.aggregations?.map((aggregation) => {
|
||||
if (query.dataSource === DataSource.METRICS) {
|
||||
const metricAggregation = aggregation as MetricAggregation;
|
||||
return {
|
||||
...aggregation,
|
||||
metricName:
|
||||
metricAggregation.metricName || query.aggregateAttribute?.key || '',
|
||||
timeAggregation:
|
||||
metricAggregation.timeAggregation || query.timeAggregation || '',
|
||||
spaceAggregation:
|
||||
metricAggregation.spaceAggregation || query.spaceAggregation || '',
|
||||
reduceTo: metricAggregation.reduceTo || query.reduceTo || 'avg',
|
||||
};
|
||||
}
|
||||
return aggregation;
|
||||
});
|
||||
|
||||
const {
|
||||
aggregateAttribute: _aggregateAttribute,
|
||||
aggregateOperator: _aggregateOperator,
|
||||
timeAggregation: _timeAggregation,
|
||||
spaceAggregation: _spaceAggregation,
|
||||
reduceTo: _reduceTo,
|
||||
filters: _filters,
|
||||
...retainedQuery
|
||||
} = query;
|
||||
|
||||
const newAggregations =
|
||||
query.dataSource === DataSource.METRICS
|
||||
? (aggregations as MetricAggregation[])
|
||||
: (aggregations as (TraceAggregation | LogAggregation)[]);
|
||||
|
||||
return {
|
||||
...retainedQuery,
|
||||
aggregations: newAggregations,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...currentQuery,
|
||||
[getBuilderSlotKeyForQueryType(currentQuery.queryType)]: {
|
||||
...activeBuilder,
|
||||
queryData: newQueryData,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return currentQuery;
|
||||
};
|
||||
|
||||
@@ -48,10 +48,8 @@ export const getFilterConfig = (
|
||||
({
|
||||
type: getFilterType(att),
|
||||
title: getFilterName(att.name),
|
||||
// The type mapping below exists only for the old v3 attribute-values fetch
|
||||
// (useCheckboxFilterValues), the sole reader of attributeKey.dataType/type.
|
||||
// Once the values fetch moves to fields/values, remove this and reduce
|
||||
// attributeKey to { id, key }.
|
||||
// TODO: nothing reads dataType/type; reduce attributeKey to { id, key }
|
||||
// once the TagFilterItem.key readers are checked.
|
||||
attributeKey: {
|
||||
id: att.name,
|
||||
key: att.name,
|
||||
|
||||
@@ -12,8 +12,6 @@ export const INVITE_MEMBERS_HASH = '#invite-team-members';
|
||||
|
||||
export const DASHBOARD_TIME_IN_DURATION = 'refreshInterval';
|
||||
|
||||
export const DEFAULT_ENTITY_VERSION = 'v3';
|
||||
export const ENTITY_VERSION_V4 = 'v4';
|
||||
export const ENTITY_VERSION_V5 = 'v5';
|
||||
|
||||
export const SIGNOZ_ADMIN_EMAIL = 'admin@signoz.cloud';
|
||||
|
||||
@@ -5,15 +5,12 @@ import {
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { createIdFromObjectFields } from 'lib/createIdFromObjectFields';
|
||||
import { createNewBuilderItemName } from 'lib/newQueryBuilder/createNewBuilderItemName';
|
||||
import { IAttributeValuesResponse } from 'types/api/queryBuilder/getAttributesValues';
|
||||
import {
|
||||
AutocompleteType,
|
||||
BaseAutocompleteData,
|
||||
DataTypes,
|
||||
LocalDataType,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import {
|
||||
HavingForm,
|
||||
IBuilderFormula,
|
||||
IBuilderQuery,
|
||||
IBuilderTraceOperator,
|
||||
@@ -57,19 +54,11 @@ export const MAX_QUERIES = 26;
|
||||
export const TRACE_OPERATOR_QUERY_NAME = 'Trace Operator';
|
||||
|
||||
export const idDivider = '--';
|
||||
export const selectValueDivider = '__';
|
||||
|
||||
export const baseAutoCompleteIdKeysOrder: (keyof Omit<
|
||||
BaseAutocompleteData,
|
||||
'id' | 'isIndexed'
|
||||
>)[] = ['key', 'dataType', 'type'];
|
||||
|
||||
export const autocompleteType: Record<AutocompleteType, AutocompleteType> = {
|
||||
resource: 'resource',
|
||||
tag: 'tag',
|
||||
'': '',
|
||||
};
|
||||
|
||||
export const formulasNames: string[] = Array.from(
|
||||
Array(MAX_FORMULAS),
|
||||
(_, i) => `F${i + 1}`,
|
||||
@@ -77,12 +66,6 @@ export const formulasNames: string[] = Array.from(
|
||||
const alpha: number[] = Array.from(Array(MAX_QUERIES), (_, i) => i + 65);
|
||||
export const alphabet: string[] = alpha.map((str) => String.fromCharCode(str));
|
||||
|
||||
export enum QueryBuilderKeys {
|
||||
GET_AGGREGATE_ATTRIBUTE = 'GET_AGGREGATE_ATTRIBUTE',
|
||||
GET_AGGREGATE_KEYS = 'GET_AGGREGATE_KEYS',
|
||||
GET_ATTRIBUTE_SUGGESTIONS = 'GET_ATTRIBUTE_SUGGESTIONS',
|
||||
}
|
||||
|
||||
export const mapOfOperators = {
|
||||
metrics: metricAggregateOperatorOptions,
|
||||
logs: logsAggregateOperatorOptions,
|
||||
@@ -110,12 +93,6 @@ export const REDUCE_TO_VALUES: SelectOption<ReduceOperators, string>[] = [
|
||||
{ value: ReduceOperators.MIN, label: 'Min of values in timeframe' },
|
||||
];
|
||||
|
||||
export const initialHavingValues: HavingForm = {
|
||||
columnName: '',
|
||||
op: '',
|
||||
value: [],
|
||||
};
|
||||
|
||||
export const initialAutocompleteData: BaseAutocompleteData = {
|
||||
id: createIdFromObjectFields(
|
||||
{ dataType: null, key: '', type: null },
|
||||
@@ -525,17 +502,6 @@ export const OPERATORS_CONFIG = {
|
||||
],
|
||||
};
|
||||
|
||||
export const HAVING_OPERATORS: string[] = [
|
||||
OPERATORS['='],
|
||||
OPERATORS['!='],
|
||||
OPERATORS.IN,
|
||||
OPERATORS.NIN,
|
||||
OPERATORS['>='],
|
||||
OPERATORS['>'],
|
||||
OPERATORS['<='],
|
||||
OPERATORS['<'],
|
||||
];
|
||||
|
||||
export enum PanelDisplay {
|
||||
TIME_SERIES = 'Time Series',
|
||||
VALUE = 'Number',
|
||||
@@ -546,21 +512,6 @@ export enum PanelDisplay {
|
||||
HISTOGRAM = 'Histogram',
|
||||
}
|
||||
|
||||
export const DATA_TYPE_VS_ATTRIBUTE_VALUES_KEY: Record<
|
||||
DataTypes,
|
||||
keyof IAttributeValuesResponse
|
||||
> = {
|
||||
[DataTypes.String]: 'stringAttributeValues',
|
||||
[DataTypes.Float64]: 'numberAttributeValues',
|
||||
[DataTypes.Int64]: 'numberAttributeValues',
|
||||
[DataTypes.bool]: 'boolAttributeValues',
|
||||
[DataTypes.ArrayFloat64]: 'numberAttributeValues',
|
||||
[DataTypes.ArrayInt64]: 'numberAttributeValues',
|
||||
[DataTypes.ArrayString]: 'stringAttributeValues',
|
||||
[DataTypes.ArrayBool]: 'boolAttributeValues',
|
||||
[DataTypes.EMPTY]: 'stringAttributeValues',
|
||||
};
|
||||
|
||||
export const listViewInitialLogQuery: Query = {
|
||||
...initialQueriesMap.logs,
|
||||
builder: {
|
||||
|
||||
@@ -2,10 +2,4 @@ import { TRACE_OPERATOR_QUERY_NAME } from './queryBuilder';
|
||||
|
||||
export const FORMULA_REGEXP = /F\d+/;
|
||||
|
||||
export const HAVING_FILTER_REGEXP = /^[-\d.,\s]+$/;
|
||||
|
||||
export const TYPE_ADDON_REGEXP = /_(.+)/;
|
||||
|
||||
export const SPLIT_FIRST_UNDERSCORE = /(?<!^)_/;
|
||||
|
||||
export const TRACE_OPERATOR_REGEXP = new RegExp(TRACE_OPERATOR_QUERY_NAME);
|
||||
|
||||
@@ -14,6 +14,7 @@ import uPlot from 'uplot';
|
||||
|
||||
import tooltipPlugin from './tooltipPlugin';
|
||||
|
||||
import 'uplot/dist/uPlot.min.css';
|
||||
import './AnomalyAlertEvaluationView.styles.scss';
|
||||
|
||||
const { Search } = Input;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import QuerySearch from 'components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch';
|
||||
import { combineInitialAndUserExpression } from 'components/QueryBuilderV2/QueryV2/QuerySearch/utils';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import {
|
||||
getAllEndpointsWidgetData,
|
||||
getGroupByExpressionFromRowData,
|
||||
@@ -156,7 +155,6 @@ function AllEndPoints({
|
||||
customOnDragSelect={(): void => {}}
|
||||
customTimeRange={timeRange}
|
||||
customOnRowClick={onRowClick}
|
||||
version={ENTITY_VERSION_V5}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useCallback, useMemo } from 'react';
|
||||
import { useQueries } from 'react-query';
|
||||
import QuerySearch from 'components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch';
|
||||
import { combineInitialAndUserExpression } from 'components/QueryBuilderV2/QueryV2/QuerySearch/utils';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import {
|
||||
END_POINT_DETAILS_QUERY_KEYS_ARRAY,
|
||||
@@ -93,13 +92,9 @@ function EndPointDetails({
|
||||
|
||||
const endPointDetailsDataQueries = useQueries(
|
||||
endPointDetailsQueryPayload.map((payload, index) => ({
|
||||
queryKey: [
|
||||
END_POINT_DETAILS_QUERY_KEYS_ARRAY[index],
|
||||
payload,
|
||||
ENTITY_VERSION_V5,
|
||||
],
|
||||
queryKey: [END_POINT_DETAILS_QUERY_KEYS_ARRAY[index], payload],
|
||||
queryFn: (): Promise<SuccessResponse<MetricRangePayloadProps>> =>
|
||||
GetMetricQueryRange(payload, ENTITY_VERSION_V5),
|
||||
GetMetricQueryRange(payload),
|
||||
enabled: !!payload,
|
||||
// Keeps the table's rows, and so its height, while a new filter loads
|
||||
keepPreviousData:
|
||||
|
||||
@@ -9,7 +9,6 @@ import { MetricRangePayloadV5, ScalarData } from 'api/v5/v5';
|
||||
import { useNavigateToExplorer } from 'components/CeleryTask/useNavigateToExplorer';
|
||||
import { combineInitialAndUserExpression } from 'components/QueryBuilderV2/QueryV2/QuerySearch/utils';
|
||||
import { withErrorBoundary } from 'components/ErrorBoundaryHOC';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import {
|
||||
formatTopErrorsDataForTable,
|
||||
@@ -76,13 +75,12 @@ function TopErrors({
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_TOP_ERRORS_BY_DOMAIN,
|
||||
queryPayload,
|
||||
ENTITY_VERSION_V5,
|
||||
showStatusCodeErrors,
|
||||
],
|
||||
queryFn: ({
|
||||
signal,
|
||||
}: QueryFunctionContext): Promise<SuccessResponseV2<MetricRangePayloadV5>> =>
|
||||
getQueryRangeV5(queryPayload, ENTITY_VERSION_V5, signal),
|
||||
getQueryRangeV5(queryPayload, signal),
|
||||
enabled: !!queryPayload,
|
||||
staleTime: 0,
|
||||
cacheTime: 0,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||
import { render, screen, waitFor } from 'tests/test-utils';
|
||||
import { TraceAggregation } from 'api/v5/v5';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { GetMetricQueryRange } from 'lib/dashboard/getQueryResults';
|
||||
import { MetricQueryRangeSuccessResponse } from 'types/api/metrics/getQueryRange';
|
||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import { SPAN_ATTRIBUTES } from '../constants';
|
||||
import DomainMetrics from './DomainMetrics';
|
||||
@@ -12,6 +13,33 @@ jest.mock('lib/dashboard/getQueryResults', () => ({
|
||||
GetMetricQueryRange: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockGetMetricQueryRange = jest.mocked(GetMetricQueryRange);
|
||||
|
||||
const buildResponse = (
|
||||
rows: { data: Record<string, string> }[],
|
||||
): MetricQueryRangeSuccessResponse => ({
|
||||
statusCode: 200,
|
||||
message: 'success',
|
||||
error: null,
|
||||
payload: {
|
||||
data: {
|
||||
resultType: '',
|
||||
newResult: { data: { result: [], resultType: '' } },
|
||||
result: [
|
||||
{ queryName: 'A', metric: {}, values: [], table: { rows, columns: [] } },
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const findQuery = (queryData: IBuilderQuery[], name: string): IBuilderQuery => {
|
||||
const query = queryData.find((q) => q.queryName === name);
|
||||
if (!query) {
|
||||
throw new Error(`Query ${name} missing from the payload`);
|
||||
}
|
||||
return query;
|
||||
};
|
||||
|
||||
// Mock ErrorState component
|
||||
jest.mock('./ErrorState', () => ({
|
||||
__esModule: true,
|
||||
@@ -36,30 +64,16 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
domainListFilterExpression: '',
|
||||
};
|
||||
|
||||
const mockSuccessResponse = {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
payload: {
|
||||
const mockSuccessResponse = buildResponse([
|
||||
{
|
||||
data: {
|
||||
result: [
|
||||
{
|
||||
table: {
|
||||
rows: [
|
||||
{
|
||||
data: {
|
||||
A: '150',
|
||||
B: '125000000',
|
||||
D: '2021-01-01T23:00:00Z',
|
||||
F1: '5.5',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
A: '150',
|
||||
B: '125000000',
|
||||
D: '2021-01-01T23:00:00Z',
|
||||
F1: '5.5',
|
||||
},
|
||||
},
|
||||
};
|
||||
]);
|
||||
|
||||
beforeEach(() => {
|
||||
queryClient = new QueryClient({
|
||||
@@ -86,7 +100,7 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
|
||||
describe('1. V5 Query Payload with Filters', () => {
|
||||
it('sends correct V5 payload structure with domain name filters', async () => {
|
||||
(GetMetricQueryRange as jest.Mock).mockResolvedValue(mockSuccessResponse);
|
||||
mockGetMetricQueryRange.mockResolvedValue(mockSuccessResponse);
|
||||
|
||||
renderComponent();
|
||||
|
||||
@@ -94,10 +108,7 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
expect(GetMetricQueryRange).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
const [payload, version] = (GetMetricQueryRange as jest.Mock).mock.calls[0];
|
||||
|
||||
// Verify it's using V5
|
||||
expect(version).toBe(ENTITY_VERSION_V5);
|
||||
const [payload] = mockGetMetricQueryRange.mock.calls[0];
|
||||
|
||||
// Verify time range
|
||||
expect(payload.start).toBe(1758259531000);
|
||||
@@ -111,64 +122,60 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
const queryData = payload.query.builder.queryData;
|
||||
|
||||
// Verify Query A - count with URL filter
|
||||
const queryA = queryData.find((q: any) => q.queryName === 'A');
|
||||
expect(queryA).toBeDefined();
|
||||
const queryA = findQuery(queryData, 'A');
|
||||
expect(queryA.dataSource).toBe('traces');
|
||||
expect(queryA.aggregations?.[0]).toBeDefined();
|
||||
expect((queryA.aggregations?.[0] as TraceAggregation)?.expression).toBe(
|
||||
'count()',
|
||||
);
|
||||
// Verify exact domain filter expression structure
|
||||
expect(queryA.filter.expression).toContain("http_host = '0.0.0.0'");
|
||||
expect(queryA.filter.expression).toContain(
|
||||
expect(queryA.filter?.expression).toContain("http_host = '0.0.0.0'");
|
||||
expect(queryA.filter?.expression).toContain(
|
||||
`${SPAN_ATTRIBUTES.HTTP_URL} EXISTS`,
|
||||
);
|
||||
|
||||
// Verify Query B - p99 latency
|
||||
const queryB = queryData.find((q: any) => q.queryName === 'B');
|
||||
expect(queryB).toBeDefined();
|
||||
const queryB = findQuery(queryData, 'B');
|
||||
expect(queryB.aggregateOperator).toBe('p99');
|
||||
expect(queryB.aggregations?.[0]).toBeDefined();
|
||||
expect((queryB.aggregations?.[0] as TraceAggregation)?.expression).toBe(
|
||||
'p99(duration_nano)',
|
||||
);
|
||||
// Verify exact domain filter expression structure
|
||||
expect(queryB.filter.expression).toContain("http_host = '0.0.0.0'");
|
||||
expect(queryB.filter?.expression).toContain("http_host = '0.0.0.0'");
|
||||
|
||||
// Verify Query C - error count (disabled)
|
||||
const queryC = queryData.find((q: any) => q.queryName === 'C');
|
||||
expect(queryC).toBeDefined();
|
||||
const queryC = findQuery(queryData, 'C');
|
||||
expect(queryC.disabled).toBe(true);
|
||||
expect(queryC.filter.expression).toContain("http_host = '0.0.0.0'");
|
||||
expect(queryC.filter?.expression).toContain("http_host = '0.0.0.0'");
|
||||
expect(queryC.aggregations?.[0]).toBeDefined();
|
||||
expect((queryC.aggregations?.[0] as TraceAggregation)?.expression).toBe(
|
||||
'count()',
|
||||
);
|
||||
|
||||
expect(queryC.filter.expression).toContain('has_error = true');
|
||||
expect(queryC.filter?.expression).toContain('has_error = true');
|
||||
|
||||
// Verify Query D - max timestamp
|
||||
const queryD = queryData.find((q: any) => q.queryName === 'D');
|
||||
expect(queryD).toBeDefined();
|
||||
const queryD = findQuery(queryData, 'D');
|
||||
expect(queryD.aggregateOperator).toBe('max');
|
||||
expect(queryD.aggregations?.[0]).toBeDefined();
|
||||
expect((queryD.aggregations?.[0] as TraceAggregation)?.expression).toBe(
|
||||
'max(timestamp)',
|
||||
);
|
||||
// Verify exact domain filter expression structure
|
||||
expect(queryD.filter.expression).toContain("http_host = '0.0.0.0'");
|
||||
expect(queryD.filter?.expression).toContain("http_host = '0.0.0.0'");
|
||||
|
||||
// Verify Formula F1 - error rate calculation
|
||||
const formulas = payload.query.builder.queryFormulas;
|
||||
expect(formulas).toBeDefined();
|
||||
expect(formulas.length).toBeGreaterThan(0);
|
||||
const formulaF1 = formulas.find((f: any) => f.queryName === 'F1');
|
||||
const formulaF1 = formulas.find((f) => f.queryName === 'F1');
|
||||
expect(formulaF1).toBeDefined();
|
||||
expect(formulaF1.expression).toBe('(C/A)*100');
|
||||
expect(formulaF1?.expression).toBe('(C/A)*100');
|
||||
});
|
||||
|
||||
it('includes custom filters in filter expressions', async () => {
|
||||
(GetMetricQueryRange as jest.Mock).mockResolvedValue(mockSuccessResponse);
|
||||
mockGetMetricQueryRange.mockResolvedValue(mockSuccessResponse);
|
||||
|
||||
const customFilterExpression =
|
||||
"service.name = 'my-service' AND deployment.environment = 'production'";
|
||||
@@ -182,24 +189,21 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
expect(GetMetricQueryRange).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
const [payload] = (GetMetricQueryRange as jest.Mock).mock.calls[0];
|
||||
const [payload] = mockGetMetricQueryRange.mock.calls[0];
|
||||
const queryData = payload.query.builder.queryData;
|
||||
|
||||
// Verify all queries include the custom filters
|
||||
queryData.forEach((query: any) => {
|
||||
if (query.filter && query.filter.expression) {
|
||||
expect(query.filter.expression).toContain('service.name');
|
||||
expect(query.filter.expression).toContain('my-service');
|
||||
expect(query.filter.expression).toContain('deployment.environment');
|
||||
expect(query.filter.expression).toContain('production');
|
||||
}
|
||||
const expressions = queryData.map((query) => query.filter?.expression);
|
||||
expect(expressions).toHaveLength(4);
|
||||
expressions.forEach((expression) => {
|
||||
expect(expression).toContain(customFilterExpression);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('2. Data Display State', () => {
|
||||
it('displays metrics when data is successfully loaded', async () => {
|
||||
(GetMetricQueryRange as jest.Mock).mockResolvedValue(mockSuccessResponse);
|
||||
mockGetMetricQueryRange.mockResolvedValue(mockSuccessResponse);
|
||||
|
||||
renderComponent();
|
||||
|
||||
@@ -220,23 +224,9 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
|
||||
describe('3. Empty/Missing Data State', () => {
|
||||
it('displays "-" for missing data values', async () => {
|
||||
const emptyResponse = {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
payload: {
|
||||
data: {
|
||||
result: [
|
||||
{
|
||||
table: {
|
||||
rows: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
const emptyResponse = buildResponse([]);
|
||||
|
||||
(GetMetricQueryRange as jest.Mock).mockResolvedValue(emptyResponse);
|
||||
mockGetMetricQueryRange.mockResolvedValue(emptyResponse);
|
||||
|
||||
renderComponent();
|
||||
|
||||
@@ -248,7 +238,7 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
|
||||
describe('4. Error State', () => {
|
||||
it('displays error state when API call fails', async () => {
|
||||
(GetMetricQueryRange as jest.Mock).mockRejectedValue(new Error('API Error'));
|
||||
mockGetMetricQueryRange.mockRejectedValue(new Error('API Error'));
|
||||
|
||||
renderComponent();
|
||||
|
||||
@@ -261,7 +251,7 @@ describe('DomainMetrics - V5 Query Payload Tests', () => {
|
||||
|
||||
it('retries API call when retry button is clicked', async () => {
|
||||
let callCount = 0;
|
||||
(GetMetricQueryRange as jest.Mock).mockImplementation(() => {
|
||||
mockGetMetricQueryRange.mockImplementation(() => {
|
||||
callCount += 1;
|
||||
if (callCount === 1) {
|
||||
return Promise.reject(new Error('API Error'));
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useQueries } from 'react-query';
|
||||
import { Skeleton, Tooltip } from 'antd';
|
||||
import { Progress } from '@signozhq/ui/progress';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import {
|
||||
DomainMetricsResponseRow,
|
||||
@@ -41,13 +40,9 @@ function DomainMetrics({
|
||||
// Since only one query here
|
||||
const domainMetricsDataQueries = useQueries(
|
||||
queryPayloads.map((payload) => ({
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_DOMAIN_METRICS_DATA,
|
||||
payload,
|
||||
ENTITY_VERSION_V5,
|
||||
],
|
||||
queryKey: [REACT_QUERY_KEY.GET_DOMAIN_METRICS_DATA, payload],
|
||||
queryFn: (): Promise<SuccessResponse<MetricRangePayloadProps>> =>
|
||||
GetMetricQueryRange(payload, ENTITY_VERSION_V5),
|
||||
GetMetricQueryRange(payload),
|
||||
enabled: !!payload,
|
||||
staleTime: 60 * 1000, // 1 minute stale time : optimize this part
|
||||
})),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery } from 'react-query';
|
||||
import { Combobox, type ComboboxItemType } from '@signozhq/ui/combobox';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import {
|
||||
getEndPointDropDownQueryPayload,
|
||||
@@ -44,12 +43,8 @@ function EndPointPicker({
|
||||
);
|
||||
|
||||
const { data, isLoading, isFetching } = useQuery({
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_ENDPOINT_DROPDOWN_DATA,
|
||||
payload,
|
||||
ENTITY_VERSION_V5,
|
||||
],
|
||||
queryFn: () => GetMetricQueryRange(payload, ENTITY_VERSION_V5),
|
||||
queryKey: [REACT_QUERY_KEY.GET_ENDPOINT_DROPDOWN_DATA, payload],
|
||||
queryFn: () => GetMetricQueryRange(payload),
|
||||
staleTime: 60 * 1000,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Card } from 'antd';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import GridCard from 'container/WidgetCard/Card';
|
||||
import { Widgets } from 'types/api/widgets/widget';
|
||||
|
||||
@@ -23,7 +22,6 @@ function MetricOverTimeGraph({
|
||||
customOnDragSelect={(): void => {}}
|
||||
customTimeRange={timeRange}
|
||||
customTimeRangeWindowForCoRelation="5m"
|
||||
version={ENTITY_VERSION_V5}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -62,7 +62,6 @@ function DomainList(): JSX.Element {
|
||||
const { handleChangeQueryData } = useQueryOperations({
|
||||
index: 0,
|
||||
query,
|
||||
entityVersion: '',
|
||||
});
|
||||
|
||||
const compositeData = useGetCompositeQueryParam();
|
||||
|
||||
@@ -99,33 +99,6 @@ describe('TopErrors', () => {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Mock V4 API endpoint for dropdown data
|
||||
server.use(
|
||||
rest.post('*/api/v1/query_range', (_req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
payload: {
|
||||
data: {
|
||||
result: [
|
||||
{
|
||||
table: {
|
||||
rows: [
|
||||
{
|
||||
http_url: '/api/test',
|
||||
A: 100,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it('renders component correctly', async () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { QueryBuilderV2 } from 'components/QueryBuilderV2/QueryBuilderV2';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -16,7 +15,6 @@ function AIQuerySection({ panelType }: AIQuerySectionProps): JSX.Element {
|
||||
initialDataSource: DataSource.TRACES,
|
||||
}}
|
||||
showTraceOperator={false}
|
||||
version={ENTITY_VERSION_V5}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import ErrorInPlace from 'components/ErrorInPlace/ErrorInPlace';
|
||||
import QueryCancelledPlaceholder from 'components/QueryCancelledPlaceholder';
|
||||
import Spinner from 'components/Spinner';
|
||||
import WarningPopover from 'components/WarningPopover/WarningPopover';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
@@ -177,7 +176,6 @@ function ChartPreview({
|
||||
},
|
||||
originalGraphType: graphType,
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.ALERT_RULES_CHART_PREVIEW,
|
||||
|
||||
@@ -6,7 +6,6 @@ import logEvent from 'api/common/logEvent';
|
||||
import PromQLIcon from 'assets/Dashboard/PromQl';
|
||||
import { QueryBuilderV2 } from 'components/QueryBuilderV2/QueryBuilderV2';
|
||||
import { ALERTS_DATA_SOURCE_MAP } from 'constants/alerts';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { QBShortcuts } from 'constants/shortcuts/QBShortcuts';
|
||||
import RunQueryBtn from 'container/QueryBuilder/components/RunQueryBtn/RunQueryBtn';
|
||||
@@ -71,7 +70,6 @@ function QuerySection({
|
||||
}}
|
||||
showTraceOperator={alertType === AlertTypes.TRACES_BASED_ALERT}
|
||||
showFunctions={alertType === AlertTypes.LOGS_BASED_ALERT}
|
||||
version={ENTITY_VERSION_V5}
|
||||
onSignalSourceChange={handleSignalSourceChange}
|
||||
signalSourceChangeEnabled
|
||||
/>
|
||||
|
||||
@@ -20,7 +20,6 @@ import Header from 'components/Header/Header';
|
||||
import HeaderRightSection from 'components/HeaderRightSection/HeaderRightSection';
|
||||
import NoAuthBanner from 'components/NoAuthBanner/NoAuthBanner';
|
||||
import { getIsNoAuthMode } from 'utils/noAuthMode';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { ORG_PREFERENCES } from 'constants/orgPreferences';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
@@ -102,7 +101,6 @@ export default function Home(): JSX.Element {
|
||||
},
|
||||
formatForWeb: false,
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_QUERY_RANGE,
|
||||
@@ -127,7 +125,6 @@ export default function Home(): JSX.Element {
|
||||
},
|
||||
formatForWeb: false,
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_QUERY_RANGE,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { QueryKey } from 'react-query';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { Button, Select, Skeleton, Table } from 'antd';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import ROUTES from 'constants/routes';
|
||||
import {
|
||||
getQueryRangeRequestData,
|
||||
@@ -226,27 +225,23 @@ function ServiceMetrics({
|
||||
[globalSelectedInterval, topLevelOperations],
|
||||
);
|
||||
|
||||
const dataQueries = useGetQueriesRange(
|
||||
queryRangeRequestData,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey: useMemo(
|
||||
() => [
|
||||
`GetMetricsQueryRange-home-${globalSelectedInterval}`,
|
||||
timeRange.endTime,
|
||||
timeRange.startTime,
|
||||
globalSelectedInterval,
|
||||
],
|
||||
[globalSelectedInterval, timeRange.endTime, timeRange.startTime],
|
||||
),
|
||||
keepPreviousData: true,
|
||||
enabled: true,
|
||||
refetchOnMount: false,
|
||||
onError: () => {
|
||||
setIsError(true);
|
||||
},
|
||||
const dataQueries = useGetQueriesRange(queryRangeRequestData, {
|
||||
queryKey: useMemo(
|
||||
() => [
|
||||
`GetMetricsQueryRange-home-${globalSelectedInterval}`,
|
||||
timeRange.endTime,
|
||||
timeRange.startTime,
|
||||
globalSelectedInterval,
|
||||
],
|
||||
[globalSelectedInterval, timeRange.endTime, timeRange.startTime],
|
||||
),
|
||||
keepPreviousData: true,
|
||||
enabled: true,
|
||||
refetchOnMount: false,
|
||||
onError: () => {
|
||||
setIsError(true);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const isLoading = useMemo(
|
||||
() => dataQueries.some((query) => query.isLoading),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useQuery, useQueryClient } from 'react-query';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { GetMetricQueryRange } from 'lib/dashboard/getQueryResults';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
@@ -77,7 +76,7 @@ export function useEntityEvents({
|
||||
offset,
|
||||
pageSize,
|
||||
});
|
||||
return GetMetricQueryRange(query, ENTITY_VERSION_V5, undefined, signal);
|
||||
return GetMetricQueryRange(query, undefined, signal);
|
||||
},
|
||||
enabled: !!expression?.trim(),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useInfiniteQuery, useQueryClient } from 'react-query';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { DEFAULT_PER_PAGE_VALUE } from 'container/Controls/config';
|
||||
import { GetMetricQueryRange } from 'lib/dashboard/getQueryResults';
|
||||
@@ -63,7 +62,7 @@ export function useInfiniteEntityLogs({
|
||||
offset: pageParam as number,
|
||||
pageSize: DEFAULT_PER_PAGE_VALUE,
|
||||
});
|
||||
return GetMetricQueryRange(query, ENTITY_VERSION_V5, undefined, signal);
|
||||
return GetMetricQueryRange(query, undefined, signal);
|
||||
},
|
||||
getNextPageParam: (lastPage, allPages) => {
|
||||
const list = lastPage?.payload?.data?.newResult?.data?.result?.[0]?.list;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { QueryFunctionContext, useQueries, UseQueryResult } from 'react-query';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { InfraMonitoringEntity } from 'container/InfraMonitoringK8sV2/constants';
|
||||
@@ -51,18 +50,12 @@ export function useEntityMetrics<T>({
|
||||
const queries = useQueries(
|
||||
queryPayloads.map((payload, index) => ({
|
||||
// TODO: remove AUTO_REFRESH_QUERY when migrating to date time selection v3
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.AUTO_REFRESH_QUERY,
|
||||
queryKey,
|
||||
payload,
|
||||
ENTITY_VERSION_V5,
|
||||
category,
|
||||
],
|
||||
queryKey: [REACT_QUERY_KEY.AUTO_REFRESH_QUERY, queryKey, payload, category],
|
||||
queryFn: ({
|
||||
signal,
|
||||
}: QueryFunctionContext): Promise<
|
||||
SuccessResponse<MetricRangePayloadProps>
|
||||
> => GetMetricQueryRange(payload, ENTITY_VERSION_V5, undefined, signal),
|
||||
> => GetMetricQueryRange(payload, undefined, signal),
|
||||
enabled: !!payload && visibilities[index],
|
||||
keepPreviousData: true,
|
||||
})),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useQuery, useQueryClient } from 'react-query';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { GetMetricQueryRange } from 'lib/dashboard/getQueryResults';
|
||||
|
||||
@@ -68,7 +67,7 @@ export function useEntityTraces({
|
||||
offset,
|
||||
pageSize,
|
||||
});
|
||||
return GetMetricQueryRange(query, ENTITY_VERSION_V5, undefined, signal);
|
||||
return GetMetricQueryRange(query, undefined, signal);
|
||||
},
|
||||
enabled: !!expression?.trim(),
|
||||
});
|
||||
|
||||
@@ -14,7 +14,6 @@ import logEvent from 'api/common/logEvent';
|
||||
import ListViewOrderBy from 'components/OrderBy/ListViewOrderBy';
|
||||
import { SavedviewtypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import type { TableColumnDef } from 'components/TanStackTableView/types';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { initialQueryAIWithType, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
@@ -144,7 +143,6 @@ function ListView({
|
||||
selectColumns,
|
||||
},
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey,
|
||||
enabled:
|
||||
|
||||
@@ -20,7 +20,6 @@ function QuerySection(): JSX.Element {
|
||||
config={{ initialDataSource: DataSource.TRACES, queryVariant: 'static' }}
|
||||
panelType={panelTypes}
|
||||
showOnlyWhereClause={isRawQuery}
|
||||
version="v3" // setting this to v3 as we this is rendered in logs explorer
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import { useSelector } from 'react-redux';
|
||||
import Space from 'periscope/components/Space/Space';
|
||||
import ErrorInPlace from 'components/ErrorInPlace/ErrorInPlace';
|
||||
import ExportMenu from 'components/ExportMenu/ExportMenu';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import { QueryTable } from 'container/QueryTable';
|
||||
@@ -68,7 +67,6 @@ function TableView({
|
||||
dataSource: 'traces',
|
||||
},
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey,
|
||||
enabled: !!stagedQuery && panelType === PANEL_TYPES.TABLE,
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
} from 'react';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useSelector } from 'react-redux';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
import TimeSeriesView from 'container/TimeSeriesView/TimeSeriesView';
|
||||
@@ -86,8 +85,6 @@ function TimeSeriesViewContainer({
|
||||
dataSource,
|
||||
},
|
||||
},
|
||||
// ENTITY_VERSION_V4,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey,
|
||||
enabled: !!stagedQuery && panelType === PANEL_TYPES.TIME_SERIES,
|
||||
|
||||
@@ -14,7 +14,6 @@ import logEvent from 'api/common/logEvent';
|
||||
import ListViewOrderBy from 'components/OrderBy/ListViewOrderBy';
|
||||
import { SavedviewtypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import type { TableColumnDef } from 'components/TanStackTableView/types';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { initialQueryAIWithType, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
@@ -139,7 +138,6 @@ function TracesView({
|
||||
pagination: paginationQueryData,
|
||||
},
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey,
|
||||
enabled: !!stagedQuery && panelType === PANEL_TYPES.TRACE,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useMemo } from 'react';
|
||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||
import { LIVE_TAIL_GRAPH_INTERVAL } from 'constants/liveTail';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import LogsExplorerChart from 'container/LogsExplorerChart';
|
||||
@@ -57,7 +56,6 @@ function LiveLogsListChart({
|
||||
const { data, isFetching } = useGetExplorerQueryRange(
|
||||
listChartQuery,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
DEFAULT_ENTITY_VERSION,
|
||||
{
|
||||
enabled: isConnectionOpen,
|
||||
refetchInterval: LIVE_TAIL_GRAPH_INTERVAL,
|
||||
|
||||
@@ -115,15 +115,6 @@ describe('ContextLogRenderer', () => {
|
||||
res(ctx.status(200), ctx.json({ logs: [mockLog] })),
|
||||
),
|
||||
);
|
||||
server.use(
|
||||
rest.post(
|
||||
`${ENVIRONMENT.baseURL}/api/v3/query_range`,
|
||||
async (req, res, ctx) => {
|
||||
capturedQueryRangePayload = await req.json();
|
||||
return res(ctx.status(200), ctx.json(mockQueryRangeResponse));
|
||||
},
|
||||
),
|
||||
);
|
||||
server.use(
|
||||
rest.post(
|
||||
`${ENVIRONMENT.baseURL}/api/v5/query_range`,
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import {
|
||||
getOrderByTimestamp,
|
||||
@@ -131,7 +130,6 @@ export const useContextLogData = ({
|
||||
const { isError, isFetching } = useGetExplorerQueryRange(
|
||||
requestData,
|
||||
PANEL_TYPES.LIST,
|
||||
DEFAULT_ENTITY_VERSION,
|
||||
{
|
||||
keepPreviousData: true,
|
||||
enabled: !!requestData,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Card, Skeleton } from 'antd';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import cx from 'classnames';
|
||||
import Uplot from 'components/Uplot';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import dayjs from 'dayjs';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
import { useResizeObserver } from 'hooks/useDimensions';
|
||||
@@ -60,9 +59,9 @@ function NodeMetrics({
|
||||
const widgetInfo = nodeName ? nodeWidgetInfo : hostWidgetInfo;
|
||||
const queries = useQueries(
|
||||
queryPayloads.map((payload) => ({
|
||||
queryKey: ['metrics', payload, ENTITY_VERSION_V5, 'NODE'],
|
||||
queryKey: ['metrics', payload, 'NODE'],
|
||||
queryFn: (): Promise<SuccessResponse<MetricRangePayloadProps>> =>
|
||||
GetMetricQueryRange(payload, ENTITY_VERSION_V5),
|
||||
GetMetricQueryRange(payload),
|
||||
enabled: !!payload,
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Card, Skeleton } from 'antd';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import cx from 'classnames';
|
||||
import Uplot from 'components/Uplot';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import dayjs from 'dayjs';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
import { useResizeObserver } from 'hooks/useDimensions';
|
||||
@@ -57,9 +56,9 @@ function PodMetrics({
|
||||
);
|
||||
const queries = useQueries(
|
||||
queryPayloads.map((payload) => ({
|
||||
queryKey: ['metrics', payload, ENTITY_VERSION_V5, 'POD'],
|
||||
queryKey: ['metrics', payload, 'POD'],
|
||||
queryFn: (): Promise<SuccessResponse<MetricRangePayloadProps>> =>
|
||||
GetMetricQueryRange(payload, ENTITY_VERSION_V5),
|
||||
GetMetricQueryRange(payload),
|
||||
enabled: !!payload,
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -168,8 +168,7 @@ const normalizeDataType = (
|
||||
): DataTypes | undefined =>
|
||||
dataType && Object.values(DataTypes).includes(dataType) ? dataType : undefined;
|
||||
|
||||
// Append a filter item (filter-in / filter-out) to a query-data item. The autocomplete
|
||||
// key is fabricated locally (empty source list), so no click-time getAggregateKeys fetch.
|
||||
// Append a filter item (filter-in / filter-out) to a query-data item.
|
||||
export const getFilterQueryData = (
|
||||
item: IBuilderQuery,
|
||||
target: Pick<LogFilterTarget, 'fieldKey' | 'dataType' | 'metricsType'>,
|
||||
|
||||
@@ -35,7 +35,6 @@ function LogExplorerQuerySection({
|
||||
config={{ initialDataSource: DataSource.LOGS, queryVariant: 'static' }}
|
||||
panelType={panelTypes}
|
||||
showOnlyWhereClause={selectedView === ExplorerViews.LIST}
|
||||
version="v3" // setting this to v3 as we this is rendered in logs explorer
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,26 +4,11 @@ import LogsExplorerViews from 'container/LogsExplorerViews';
|
||||
import { mockQueryBuilderContextValue } from 'container/LogsExplorerViews/tests/mock';
|
||||
import { useGetExplorerQueryRange } from 'hooks/queryBuilder/useGetExplorerQueryRange';
|
||||
import { logsQueryRangeEmptyResponse } from 'mocks-server/__mockdata__/logs_query_range';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { PreferenceContextProvider } from 'providers/preferences/context/PreferenceContextProvider';
|
||||
import { QueryBuilderContext } from 'providers/QueryBuilder';
|
||||
import { mockAppLocation } from 'tests/router-mocks';
|
||||
import { render, screen } from 'tests/test-utils';
|
||||
|
||||
const queryRangeURL = 'http://localhost/api/v3/query_range';
|
||||
|
||||
const logsQueryServerRequest = ({
|
||||
response = logsQueryRangeEmptyResponse,
|
||||
}: {
|
||||
response?: any;
|
||||
}): void =>
|
||||
server.use(
|
||||
rest.post(queryRangeURL, (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(response)),
|
||||
),
|
||||
);
|
||||
|
||||
mockAppLocation({ pathname: ROUTES.LOGS_EXPLORER });
|
||||
|
||||
jest.mock('providers/preferences/sync/usePreferenceSync', () => ({
|
||||
@@ -78,7 +63,6 @@ describe('LogsExplorerList - empty states', () => {
|
||||
(useGetExplorerQueryRange as jest.Mock).mockReturnValue({
|
||||
data: { payload: logsQueryRangeEmptyResponse },
|
||||
});
|
||||
logsQueryServerRequest({});
|
||||
});
|
||||
|
||||
it('should display custom empty state when navigating from trace to logs with no results', async () => {
|
||||
|
||||
@@ -14,7 +14,6 @@ import { useSelector } from 'react-redux';
|
||||
import getFromLocalstorage from 'api/browser/localstorage/get';
|
||||
import setToLocalstorage from 'api/browser/localstorage/set';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import {
|
||||
@@ -148,7 +147,6 @@ function LogsExplorerViewsContainer({
|
||||
} = useGetExplorerQueryRange(
|
||||
listChartQuery,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
enabled:
|
||||
showFrequencyChart &&
|
||||
@@ -166,7 +164,6 @@ function LogsExplorerViewsContainer({
|
||||
useGetExplorerQueryRange(
|
||||
requestData,
|
||||
selectedPanelType,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
keepPreviousData: true,
|
||||
enabled: !isLimit && !!requestData,
|
||||
|
||||
@@ -3,9 +3,6 @@ import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||
import { useGetExplorerQueryRange } from 'hooks/queryBuilder/useGetExplorerQueryRange';
|
||||
import { logsQueryRangeSuccessResponse } from 'mocks-server/__mockdata__/logs_query_range';
|
||||
import { server } from 'mocks-server/server';
|
||||
import { rest } from 'msw';
|
||||
import { PreferenceContextProvider } from 'providers/preferences/context/PreferenceContextProvider';
|
||||
import { QueryBuilderContext } from 'providers/QueryBuilder';
|
||||
import { mockAppLocation } from 'tests/router-mocks';
|
||||
@@ -26,17 +23,9 @@ import {
|
||||
mockQueryBuilderContextValue,
|
||||
} from './mock';
|
||||
|
||||
const queryRangeURL = 'http://localhost/api/v3/query_range';
|
||||
const ACTIVE_LOG_ID = 'test-log-id';
|
||||
mockAppLocation({ pathname: ROUTES.LOGS_EXPLORER });
|
||||
|
||||
const lodsQueryServerRequest = (): void =>
|
||||
server.use(
|
||||
rest.post(queryRangeURL, (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(logsQueryRangeSuccessResponse)),
|
||||
),
|
||||
);
|
||||
|
||||
// mocking the graph components in this test as this should be handled separately
|
||||
jest.mock(
|
||||
'container/TimeSeriesView/TimeSeriesView',
|
||||
@@ -126,7 +115,6 @@ const renderer = (): RenderResult =>
|
||||
|
||||
describe('LogsExplorerViews -', () => {
|
||||
it('render correctly with props - list and table', async () => {
|
||||
lodsQueryServerRequest();
|
||||
const { queryByTestId } = renderer();
|
||||
|
||||
const periscopeDownloadButtonTestId = 'periscope-btn-download-logs';
|
||||
@@ -152,7 +140,6 @@ describe('LogsExplorerViews -', () => {
|
||||
});
|
||||
|
||||
it('check isLoading state', async () => {
|
||||
lodsQueryServerRequest();
|
||||
(useGetExplorerQueryRange as jest.Mock).mockReturnValue({
|
||||
data: { payload: logsQueryRangeSuccessNewFormatResponse },
|
||||
isLoading: true,
|
||||
@@ -174,7 +161,6 @@ describe('LogsExplorerViews -', () => {
|
||||
mockQueryBuilderContextValue.currentQuery.builder.queryData[0].filters?.items
|
||||
.length || 0;
|
||||
|
||||
lodsQueryServerRequest();
|
||||
render(
|
||||
<QueryBuilderContext.Provider value={mockQueryBuilderContextValue}>
|
||||
<PreferenceContextProvider>
|
||||
@@ -250,8 +236,6 @@ describe('LogsExplorerViews -', () => {
|
||||
},
|
||||
};
|
||||
|
||||
lodsQueryServerRequest();
|
||||
|
||||
render(
|
||||
<QueryBuilderContext.Provider value={customContext as any}>
|
||||
<PreferenceContextProvider>
|
||||
|
||||
@@ -118,7 +118,7 @@ function Section(section: MetricSection): JSX.Element {
|
||||
$panelType={PANEL_TYPES.BAR}
|
||||
className="meter-graph"
|
||||
>
|
||||
<GridCard widget={widget} onDragSelect={onDragSelect} version="v5" />
|
||||
<GridCard widget={widget} onDragSelect={onDragSelect} />
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -109,7 +109,6 @@ function Explorer(): JSX.Element {
|
||||
}}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
showFunctions={false}
|
||||
version="v3"
|
||||
/>
|
||||
|
||||
<div className="explore-content">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useQueries } from 'react-query';
|
||||
import { isAxiosError } from 'axios';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { initialQueryMeterWithType, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { MAX_QUERY_RETRIES } from 'constants/reactQuery';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
@@ -72,7 +71,6 @@ export function useTimeSeriesQueries({
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_QUERY_RANGE,
|
||||
payload,
|
||||
ENTITY_VERSION_V5,
|
||||
globalSelectedTime,
|
||||
maxTime,
|
||||
minTime,
|
||||
@@ -93,7 +91,6 @@ export function useTimeSeriesQueries({
|
||||
dataSource: DataSource.METRICS,
|
||||
},
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
undefined,
|
||||
signal,
|
||||
),
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useAppLocation } from 'lib/router/useAppLocation';
|
||||
import { useAppParams } from 'lib/router/useAppParams';
|
||||
import Col from 'periscope/components/Col/Col';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import Graph from 'container/WidgetCard/Card';
|
||||
@@ -201,7 +200,6 @@ function DBCall(): JSX.Element {
|
||||
);
|
||||
}}
|
||||
onDragSelect={onDragSelect}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
@@ -240,7 +238,6 @@ function DBCall(): JSX.Element {
|
||||
);
|
||||
}}
|
||||
onDragSelect={onDragSelect}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useAppLocation } from 'lib/router/useAppLocation';
|
||||
import { useAppParams } from 'lib/router/useAppParams';
|
||||
import Col from 'periscope/components/Col/Col';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import Graph from 'container/WidgetCard/Card';
|
||||
@@ -273,7 +272,6 @@ function External(): JSX.Element {
|
||||
);
|
||||
}}
|
||||
onDragSelect={onDragSelect}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
@@ -317,7 +315,6 @@ function External(): JSX.Element {
|
||||
);
|
||||
}}
|
||||
onDragSelect={onDragSelect}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
@@ -362,7 +359,6 @@ function External(): JSX.Element {
|
||||
)
|
||||
}
|
||||
onDragSelect={onDragSelect}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
@@ -406,7 +402,6 @@ function External(): JSX.Element {
|
||||
);
|
||||
}}
|
||||
onDragSelect={onDragSelect}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
apDexToolTipUrl,
|
||||
apDexToolTipUrlText,
|
||||
} from 'constants/apDex';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import Graph from 'container/WidgetCard/Card';
|
||||
import DisplayThreshold from 'container/WidgetCard/Header/DisplayThreshold';
|
||||
@@ -104,7 +103,6 @@ function ApDexMetrics({
|
||||
onClickHandler={handleGraphClick('ApDex')}
|
||||
threshold={threshold}
|
||||
isQueryEnabled={isQueryEnabled}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useAppParams } from 'lib/router/useAppParams';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { FeatureKeys } from 'constants/features';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import Graph from 'container/WidgetCard/Card';
|
||||
@@ -119,7 +118,6 @@ function ServiceOverview({
|
||||
widget={latencyWidget}
|
||||
onClickHandler={handleGraphClick('Service')}
|
||||
isQueryEnabled={isQueryEnabled}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import axios from 'axios';
|
||||
import { SOMETHING_WENT_WRONG } from 'constants/api';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import Graph from 'container/WidgetCard/Card';
|
||||
import { SERVICE_DETAIL_DRILLDOWN_ENABLED } from 'container/MetricsApplication/constant';
|
||||
import { Card, GraphContainer } from 'container/MetricsApplication/styles';
|
||||
@@ -40,7 +39,6 @@ function TopLevelOperation({
|
||||
onClickHandler={handleGraphClick(opName)}
|
||||
onDragSelect={onDragSelect}
|
||||
isQueryEnabled={!topLevelOperationsIsLoading}
|
||||
version={ENTITY_VERSION_V5}
|
||||
enableDrillDown={SERVICE_DETAIL_DRILLDOWN_ENABLED}
|
||||
/>
|
||||
</GraphContainer>
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ReactNode, useMemo } from 'react';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useAppParams } from 'lib/router/useAppParams';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { topOperationMetricsDownloadOptions } from 'container/MetricsApplication/constant';
|
||||
import { getWidgetQueryBuilder } from 'container/MetricsApplication/MetricsApplication.factory';
|
||||
@@ -71,7 +70,6 @@ function TopOperationMetrics(): JSX.Element {
|
||||
globalSelectedInterval,
|
||||
variables: {},
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey: [
|
||||
`GetMetricsQueryRange-${keyOperationWidget?.timePreferance}-${globalSelectedInterval}-${keyOperationWidget?.id}`,
|
||||
|
||||
@@ -340,7 +340,6 @@ function Explorer(): JSX.Element {
|
||||
config={{ initialDataSource: DataSource.METRICS, queryVariant: 'static' }}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
showFunctions={false}
|
||||
version="v3"
|
||||
/>
|
||||
<div className="explore-content">
|
||||
<TimeSeries
|
||||
|
||||
@@ -16,7 +16,6 @@ import classNames from 'classnames';
|
||||
import QueryCancelledPlaceholder from 'components/QueryCancelledPlaceholder';
|
||||
import YAxisUnitSelector from 'components/YAxisUnitSelector';
|
||||
import { YAxisSource } from 'components/YAxisUnitSelector/types';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { MAX_QUERY_RETRIES } from 'constants/reactQuery';
|
||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||
@@ -101,7 +100,6 @@ function TimeSeries({
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.GET_QUERY_RANGE,
|
||||
payload,
|
||||
ENTITY_VERSION_V5,
|
||||
globalSelectedTime,
|
||||
maxTime,
|
||||
minTime,
|
||||
@@ -122,8 +120,6 @@ function TimeSeries({
|
||||
dataSource: DataSource.METRICS,
|
||||
},
|
||||
},
|
||||
// ENTITY_VERSION_V4,
|
||||
ENTITY_VERSION_V5,
|
||||
undefined,
|
||||
signal,
|
||||
),
|
||||
|
||||
@@ -60,7 +60,6 @@ function Inspect({
|
||||
const { handleChangeQueryData } = useQueryOperations({
|
||||
index: 0,
|
||||
query: currentQuery.builder.queryData[0],
|
||||
entityVersion: '',
|
||||
});
|
||||
|
||||
const updatedCurrentQuery = useMemo(
|
||||
|
||||
@@ -172,17 +172,6 @@ const useOptionsMenu = ({
|
||||
{ queryKey: [debouncedSearchText, isFocused], enabled: isFocused },
|
||||
);
|
||||
|
||||
// const {
|
||||
// data: searchedAttributesData,
|
||||
// isFetching: isSearchedAttributesFetching,
|
||||
// } = useGetAggregateKeys(
|
||||
// {
|
||||
// ...initialQueryParams,
|
||||
// searchText: debouncedSearchText,
|
||||
// },
|
||||
// { queryKey: [debouncedSearchText, isFocused], enabled: isFocused },
|
||||
// );
|
||||
|
||||
const searchedAttributeKeys: TelemetryFieldKey[] = useMemo(() => {
|
||||
const searchedAttributesDataList = Object.values(
|
||||
searchedAttributesDataV5?.data.data.keys || {},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useMemo } from 'react';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import {
|
||||
initialFilters,
|
||||
initialQueriesMap,
|
||||
@@ -27,15 +26,12 @@ function LogsCountInInterval({
|
||||
return q;
|
||||
}, [filter]);
|
||||
|
||||
const result = useGetQueryRange(
|
||||
{
|
||||
graphType: PANEL_TYPES.TABLE,
|
||||
query,
|
||||
selectedTime: 'GLOBAL_TIME',
|
||||
globalSelectedInterval: timeInterval,
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
);
|
||||
const result = useGetQueryRange({
|
||||
graphType: PANEL_TYPES.TABLE,
|
||||
query,
|
||||
selectedTime: 'GLOBAL_TIME',
|
||||
globalSelectedInterval: timeInterval,
|
||||
});
|
||||
|
||||
const count = useMemo(() => {
|
||||
const table = result.data?.payload?.data?.result?.[0]?.table;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { useMemo } from 'react';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import {
|
||||
initialFilters,
|
||||
initialQueriesMap,
|
||||
@@ -43,15 +42,12 @@ const useSampleLogs = ({
|
||||
return q;
|
||||
}, [count, filter]);
|
||||
|
||||
const response = useGetQueryRange(
|
||||
{
|
||||
graphType: PANEL_TYPES.LIST,
|
||||
query,
|
||||
selectedTime: 'GLOBAL_TIME',
|
||||
globalSelectedInterval: timeInterval,
|
||||
},
|
||||
ENTITY_VERSION_V5,
|
||||
);
|
||||
const response = useGetQueryRange({
|
||||
graphType: PANEL_TYPES.LIST,
|
||||
query,
|
||||
selectedTime: 'GLOBAL_TIME',
|
||||
globalSelectedInterval: timeInterval,
|
||||
});
|
||||
|
||||
const { isFetching: isLoading, data } = response;
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ export type QueryBuilderProps = {
|
||||
showOnlyTraceOperator?: boolean;
|
||||
showTraceViewSelector?: boolean;
|
||||
showTraceOperator?: boolean;
|
||||
version: string;
|
||||
onChangeTraceView?: (view: TraceView) => void;
|
||||
onSignalSourceChange?: (value: string) => void;
|
||||
signalSourceChangeEnabled?: boolean;
|
||||
|
||||
@@ -40,7 +40,6 @@ export function Formula({
|
||||
index,
|
||||
query,
|
||||
formula,
|
||||
entityVersion: '',
|
||||
});
|
||||
|
||||
const [isCollapse, setIsCollapsed] = useState(false);
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
export type HavingFilterTagProps = {
|
||||
label: ReactNode;
|
||||
value: string;
|
||||
disabled: boolean;
|
||||
onClose: VoidFunction;
|
||||
closable: boolean;
|
||||
onUpdate: (value: string) => void;
|
||||
};
|
||||
|
||||
export type HavingTagRenderProps = Omit<HavingFilterTagProps, 'onUpdate'>;
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const StyledText = styled.span`
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
export const StyledTag = styled(Badge).attrs({
|
||||
color: 'secondary' as const,
|
||||
variant: 'solid' as const,
|
||||
})`
|
||||
margin-top: 0.125rem;
|
||||
margin-bottom: 0.125rem;
|
||||
padding-left: 0.5rem;
|
||||
display: flex;
|
||||
`;
|
||||
@@ -1,38 +0,0 @@
|
||||
import { X } from '@signozhq/icons';
|
||||
|
||||
import { HavingFilterTagProps } from './HavingFilterTag.interfaces';
|
||||
import { StyledTag, StyledText } from './HavingFilterTag.styled';
|
||||
|
||||
export function HavingFilterTag({
|
||||
value,
|
||||
closable,
|
||||
onClose,
|
||||
onUpdate,
|
||||
}: HavingFilterTagProps): JSX.Element {
|
||||
const handleClick = (): void => {
|
||||
onUpdate(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledTag
|
||||
suffix={
|
||||
closable ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Remove"
|
||||
onClick={(e): void => {
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
<X size={12} />
|
||||
</button>
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
<span role="button" tabIndex={0} onClick={handleClick}>
|
||||
<StyledText>{value}</StyledText>
|
||||
</span>
|
||||
</StyledTag>
|
||||
);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import { render, screen, userEvent } from 'tests/test-utils';
|
||||
|
||||
import { HavingFilterTag } from '../HavingFilterTag';
|
||||
|
||||
// Badge renders its suffix inside an aria-hidden span.
|
||||
const getRemoveButton = (): HTMLElement =>
|
||||
screen.getByRole('button', { name: 'Remove', hidden: true });
|
||||
|
||||
function renderTag(closable: boolean): {
|
||||
onClose: jest.Mock;
|
||||
onUpdate: jest.Mock;
|
||||
} {
|
||||
const onClose = jest.fn();
|
||||
const onUpdate = jest.fn();
|
||||
render(
|
||||
<HavingFilterTag
|
||||
label="count() > 5"
|
||||
value="count() > 5"
|
||||
disabled={false}
|
||||
closable={closable}
|
||||
onClose={onClose}
|
||||
onUpdate={onUpdate}
|
||||
/>,
|
||||
);
|
||||
return { onClose, onUpdate };
|
||||
}
|
||||
|
||||
describe('HavingFilterTag', () => {
|
||||
it('calls onClose once when the remove button is clicked', async () => {
|
||||
const { onClose, onUpdate } = renderTag(true);
|
||||
|
||||
await userEvent.click(getRemoveButton());
|
||||
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
expect(onUpdate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('renders no remove button when not closable', () => {
|
||||
renderTag(false);
|
||||
|
||||
expect(
|
||||
screen.queryByRole('button', { name: 'Remove', hidden: true }),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onUpdate with the value when the chip body is clicked', async () => {
|
||||
const { onClose, onUpdate } = renderTag(true);
|
||||
|
||||
await userEvent.click(screen.getByText('count() > 5'));
|
||||
|
||||
expect(onUpdate).toHaveBeenCalledTimes(1);
|
||||
expect(onUpdate).toHaveBeenCalledWith('count() > 5');
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
export { HavingFilterTag } from './HavingFilterTag';
|
||||
@@ -1,5 +1,4 @@
|
||||
export { DataSourceDropdown } from './DataSourceDropdown';
|
||||
export { Formula } from './Formula';
|
||||
export { HavingFilterTag } from './HavingFilterTag';
|
||||
export { ListItemWrapper } from './ListItemWrapper';
|
||||
export { ListMarker } from './ListMarker';
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { AutoCompleteProps } from 'antd';
|
||||
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
export type AgregatorFilterProps = Pick<AutoCompleteProps, 'disabled'> & {
|
||||
query: IBuilderQuery;
|
||||
onChange: (value: BaseAutocompleteData, isEditMode?: boolean) => void;
|
||||
defaultValue?: string;
|
||||
onSelect?: (value: BaseAutocompleteData) => void;
|
||||
index?: number;
|
||||
signalSource?: 'meter' | '';
|
||||
setAttributeKeys?: (keys: BaseAutocompleteData[]) => void;
|
||||
};
|
||||
@@ -1,307 +0,0 @@
|
||||
// ** Components
|
||||
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useQuery, useQueryClient } from 'react-query';
|
||||
import { AutoComplete, Spin } from 'antd';
|
||||
// ** Api
|
||||
import { getAggregateAttribute } from 'api/queryBuilder/getAggregateAttribute';
|
||||
import {
|
||||
baseAutoCompleteIdKeysOrder,
|
||||
QueryBuilderKeys,
|
||||
selectValueDivider,
|
||||
} from 'constants/queryBuilder';
|
||||
import { DEBOUNCE_DELAY } from 'constants/queryBuilderFilterConfig';
|
||||
import useDebounce from 'hooks/useDebounce';
|
||||
import { createIdFromObjectFields } from 'lib/createIdFromObjectFields';
|
||||
import { chooseAutocompleteFromCustomValue } from 'lib/newQueryBuilder/chooseAutocompleteFromCustomValue';
|
||||
import { getAutocompleteValueAndType } from 'lib/newQueryBuilder/getAutocompleteValueAndType';
|
||||
import { SuccessResponse } from 'types/api';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
IQueryAutocompleteResponse,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { MetricAggregation } from 'types/api/v5/queryRange';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { ExtendedSelectOption } from 'types/common/select';
|
||||
import { useSelectPopupContainer } from 'utils/selectPopupContainer';
|
||||
|
||||
import { selectStyle } from '../QueryBuilderSearchV2/config';
|
||||
import OptionRenderer from '../OptionRenderer/OptionRenderer';
|
||||
// ** Types
|
||||
import { AgregatorFilterProps } from './AggregatorFilter.intefaces';
|
||||
|
||||
export const AggregatorFilter = memo(function AggregatorFilter({
|
||||
query,
|
||||
disabled,
|
||||
onChange,
|
||||
defaultValue,
|
||||
onSelect,
|
||||
index,
|
||||
signalSource,
|
||||
setAttributeKeys,
|
||||
}: AgregatorFilterProps): JSX.Element {
|
||||
const getPopupContainer = useSelectPopupContainer();
|
||||
const queryClient = useQueryClient();
|
||||
const [optionsData, setOptionsData] = useState<ExtendedSelectOption[]>([]);
|
||||
|
||||
// this function is only relevant for metrics and now operators are part of aggregations
|
||||
const queryAggregation = useMemo(
|
||||
() => query.aggregations?.[0] as MetricAggregation,
|
||||
[query.aggregations],
|
||||
);
|
||||
|
||||
const [searchText, setSearchText] = useState<string>(
|
||||
(query.aggregations?.[0] as MetricAggregation)?.metricName || '',
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setSearchText('');
|
||||
}, [signalSource]);
|
||||
|
||||
const debouncedSearchText = useMemo(() => {
|
||||
const [_, value] = getAutocompleteValueAndType(searchText);
|
||||
|
||||
return value;
|
||||
}, [searchText]);
|
||||
|
||||
const debouncedValue = useDebounce(debouncedSearchText, DEBOUNCE_DELAY);
|
||||
const { isFetching, data: aggregateAttributeData } = useQuery(
|
||||
[
|
||||
QueryBuilderKeys.GET_AGGREGATE_ATTRIBUTE,
|
||||
debouncedValue,
|
||||
queryAggregation.timeAggregation,
|
||||
query.dataSource,
|
||||
index,
|
||||
signalSource,
|
||||
],
|
||||
async () =>
|
||||
getAggregateAttribute({
|
||||
searchText: debouncedValue,
|
||||
aggregateOperator: queryAggregation.timeAggregation,
|
||||
dataSource: query.dataSource,
|
||||
source: signalSource || '',
|
||||
}),
|
||||
{
|
||||
enabled:
|
||||
query.dataSource === DataSource.METRICS ||
|
||||
(!!queryAggregation.timeAggregation && !!query.dataSource),
|
||||
onSuccess: (data) => {
|
||||
const options: ExtendedSelectOption[] =
|
||||
data?.payload?.attributeKeys?.map(({ id: _, ...item }) => ({
|
||||
label: (
|
||||
<OptionRenderer
|
||||
label={item.key}
|
||||
value={item.key}
|
||||
dataType={item.dataType}
|
||||
type={item.type || ''}
|
||||
/>
|
||||
),
|
||||
value: `${item.key}${selectValueDivider}${createIdFromObjectFields(
|
||||
item,
|
||||
baseAutoCompleteIdKeysOrder,
|
||||
)}`,
|
||||
key: createIdFromObjectFields(item, baseAutoCompleteIdKeysOrder),
|
||||
})) || [];
|
||||
|
||||
setOptionsData(options);
|
||||
setAttributeKeys?.(data?.payload?.attributeKeys || []);
|
||||
},
|
||||
keepPreviousData: false,
|
||||
},
|
||||
);
|
||||
|
||||
// Handle edit mode: update aggregateAttribute type when data is available
|
||||
useEffect(() => {
|
||||
const metricName = queryAggregation?.metricName;
|
||||
const hasAggregateAttributeType = query.aggregateAttribute?.type;
|
||||
|
||||
// Check if we're in edit mode and have data from the existing query
|
||||
// Also ensure this is for the correct query by checking the metric name matches
|
||||
if (
|
||||
query.dataSource === DataSource.METRICS &&
|
||||
metricName &&
|
||||
!hasAggregateAttributeType &&
|
||||
aggregateAttributeData?.payload?.attributeKeys &&
|
||||
// Only update if the data contains the metric we're looking for
|
||||
aggregateAttributeData.payload.attributeKeys.some(
|
||||
(item) => item.key === metricName,
|
||||
)
|
||||
) {
|
||||
const metricData = aggregateAttributeData.payload.attributeKeys.find(
|
||||
(item) => item.key === metricName,
|
||||
);
|
||||
|
||||
if (metricData) {
|
||||
// Update the aggregateAttribute with the fetched type information
|
||||
onChange(metricData, true);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
query.dataSource,
|
||||
queryAggregation?.metricName,
|
||||
query.aggregateAttribute?.type,
|
||||
aggregateAttributeData,
|
||||
onChange,
|
||||
index,
|
||||
query,
|
||||
setAttributeKeys,
|
||||
]);
|
||||
|
||||
const handleSearchText = useCallback((text: string): void => {
|
||||
setSearchText(text);
|
||||
}, []);
|
||||
|
||||
const getPlaceholder = useCallback(() => {
|
||||
if (signalSource === 'meter') {
|
||||
return 'Meter name';
|
||||
}
|
||||
|
||||
if (query.dataSource === DataSource.METRICS) {
|
||||
return 'Metric name';
|
||||
}
|
||||
|
||||
return 'Aggregate attribute';
|
||||
}, [signalSource, query.dataSource]);
|
||||
|
||||
const getAttributesData = useCallback((): BaseAutocompleteData[] => {
|
||||
const attributeKeys =
|
||||
queryClient.getQueryData<SuccessResponse<IQueryAutocompleteResponse>>([
|
||||
QueryBuilderKeys.GET_AGGREGATE_ATTRIBUTE,
|
||||
debouncedValue,
|
||||
queryAggregation.timeAggregation,
|
||||
query.dataSource,
|
||||
index,
|
||||
signalSource,
|
||||
])?.payload?.attributeKeys || [];
|
||||
|
||||
setAttributeKeys?.(attributeKeys);
|
||||
|
||||
return attributeKeys;
|
||||
}, [
|
||||
debouncedValue,
|
||||
queryAggregation.timeAggregation,
|
||||
query.dataSource,
|
||||
queryClient,
|
||||
index,
|
||||
signalSource,
|
||||
setAttributeKeys,
|
||||
]);
|
||||
|
||||
const getResponseAttributes = useCallback(async () => {
|
||||
const response = await queryClient.fetchQuery(
|
||||
[
|
||||
QueryBuilderKeys.GET_AGGREGATE_ATTRIBUTE,
|
||||
searchText,
|
||||
queryAggregation.timeAggregation,
|
||||
query.dataSource,
|
||||
index,
|
||||
],
|
||||
async () =>
|
||||
getAggregateAttribute({
|
||||
searchText,
|
||||
aggregateOperator: queryAggregation.timeAggregation,
|
||||
dataSource: query.dataSource,
|
||||
}),
|
||||
);
|
||||
|
||||
setAttributeKeys?.(response.payload?.attributeKeys || []);
|
||||
return response.payload?.attributeKeys || [];
|
||||
}, [
|
||||
queryAggregation.timeAggregation,
|
||||
query.dataSource,
|
||||
queryClient,
|
||||
searchText,
|
||||
index,
|
||||
setAttributeKeys,
|
||||
]);
|
||||
|
||||
const handleChangeCustomValue = useCallback(
|
||||
async (value: string, attributes: BaseAutocompleteData[]) => {
|
||||
const customAttribute: BaseAutocompleteData =
|
||||
chooseAutocompleteFromCustomValue(attributes, value);
|
||||
|
||||
onChange(customAttribute);
|
||||
},
|
||||
[onChange],
|
||||
);
|
||||
|
||||
const handleBlur = useCallback(async () => {
|
||||
if (searchText && searchText !== queryAggregation.metricName) {
|
||||
const aggregateAttributes = await getResponseAttributes();
|
||||
handleChangeCustomValue(searchText, aggregateAttributes);
|
||||
}
|
||||
}, [
|
||||
getResponseAttributes,
|
||||
handleChangeCustomValue,
|
||||
searchText,
|
||||
queryAggregation?.metricName,
|
||||
]);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(
|
||||
value: string,
|
||||
option: ExtendedSelectOption | ExtendedSelectOption[],
|
||||
): void => {
|
||||
const currentOption = option as ExtendedSelectOption;
|
||||
|
||||
const aggregateAttributes = getAttributesData();
|
||||
|
||||
if (currentOption.key) {
|
||||
const attribute = aggregateAttributes.find(
|
||||
(item) => item.id === currentOption.key,
|
||||
);
|
||||
|
||||
if (attribute) {
|
||||
onChange(attribute);
|
||||
}
|
||||
} else {
|
||||
handleChangeCustomValue(value, aggregateAttributes);
|
||||
}
|
||||
|
||||
setSearchText('');
|
||||
},
|
||||
[getAttributesData, handleChangeCustomValue, onChange],
|
||||
);
|
||||
|
||||
const handleSelect = useCallback(
|
||||
(_: string, option: ExtendedSelectOption | ExtendedSelectOption[]): void => {
|
||||
const currentOption = option as ExtendedSelectOption;
|
||||
|
||||
const aggregateAttributes = getAttributesData();
|
||||
|
||||
if (currentOption.key) {
|
||||
const attribute = aggregateAttributes.find(
|
||||
(item) => item.id === currentOption.key,
|
||||
);
|
||||
|
||||
if (attribute && onSelect) {
|
||||
onSelect(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
setSearchText('');
|
||||
},
|
||||
[getAttributesData, onSelect],
|
||||
);
|
||||
|
||||
const value =
|
||||
(query.aggregations?.[0] as MetricAggregation)?.metricName ||
|
||||
query.aggregateAttribute?.key ||
|
||||
'';
|
||||
|
||||
return (
|
||||
<AutoComplete
|
||||
getPopupContainer={getPopupContainer}
|
||||
placeholder={getPlaceholder()}
|
||||
style={selectStyle}
|
||||
filterOption={false}
|
||||
onSearch={handleSearchText}
|
||||
notFoundContent={isFetching ? <Spin size="small" /> : null}
|
||||
options={optionsData}
|
||||
value={defaultValue || value}
|
||||
onBlur={handleBlur}
|
||||
onChange={handleChange}
|
||||
disabled={disabled}
|
||||
onSelect={handleSelect}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
export { AggregatorFilter } from './AggregatorFilter';
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Having, IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
export type HavingFilterProps = {
|
||||
entityVersion: string;
|
||||
query: IBuilderQuery;
|
||||
onChange: (having: Having[]) => void;
|
||||
};
|
||||
@@ -1,265 +0,0 @@
|
||||
// ** Helpers
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
import { Select } from 'antd';
|
||||
import { ENTITY_VERSION_V4 } from 'constants/app';
|
||||
// ** Constants
|
||||
import { HAVING_OPERATORS, initialHavingValues } from 'constants/queryBuilder';
|
||||
import { HavingFilterTag } from 'container/QueryBuilder/components';
|
||||
import { HavingTagRenderProps } from 'container/QueryBuilder/components/HavingFilterTag/HavingFilterTag.interfaces';
|
||||
// ** Hooks
|
||||
import { useTagValidation } from 'hooks/queryBuilder/useTagValidation';
|
||||
import {
|
||||
transformFromStringToHaving,
|
||||
transformHavingToStringValue,
|
||||
} from 'lib/query/transformQueryBuilderData';
|
||||
import { Having, HavingForm } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { SelectOption } from 'types/common/select';
|
||||
import { useSelectPopupContainer } from 'utils/selectPopupContainer';
|
||||
|
||||
import { getHavingObject, isValidHavingValue } from '../utils';
|
||||
// ** Types
|
||||
import { HavingFilterProps } from './HavingFilter.interfaces';
|
||||
|
||||
export function HavingFilter({
|
||||
entityVersion,
|
||||
query,
|
||||
onChange,
|
||||
}: HavingFilterProps): JSX.Element {
|
||||
const getPopupContainer = useSelectPopupContainer();
|
||||
const { having } = query;
|
||||
const [searchText, setSearchText] = useState<string>('');
|
||||
const [options, setOptions] = useState<SelectOption<string, string>[]>([]);
|
||||
const [localValues, setLocalValues] = useState<string[]>([]);
|
||||
const [currentFormValue, setCurrentFormValue] =
|
||||
useState<HavingForm>(initialHavingValues);
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
|
||||
const { isMulti } = useTagValidation(
|
||||
currentFormValue.op,
|
||||
currentFormValue.value,
|
||||
);
|
||||
|
||||
const aggregatorAttribute = useMemo(
|
||||
() => query.aggregateAttribute?.key || '',
|
||||
[query],
|
||||
);
|
||||
|
||||
const columnName = useMemo(() => {
|
||||
if (
|
||||
query &&
|
||||
query.dataSource === DataSource.METRICS &&
|
||||
query.spaceAggregation &&
|
||||
entityVersion === ENTITY_VERSION_V4
|
||||
) {
|
||||
return `${query.spaceAggregation.toUpperCase()}(${aggregatorAttribute})`;
|
||||
}
|
||||
|
||||
return `${
|
||||
query.aggregateOperator?.toUpperCase() || ''
|
||||
}(${aggregatorAttribute})`;
|
||||
}, [query, aggregatorAttribute, entityVersion]);
|
||||
|
||||
const aggregatorOptions: SelectOption<string, string>[] = useMemo(
|
||||
() => [{ label: columnName, value: columnName }],
|
||||
[columnName],
|
||||
);
|
||||
|
||||
const generateOptions = useCallback(
|
||||
(search: string): void => {
|
||||
const [aggregator = '', op = '', ...restValue] = search.split(' ');
|
||||
let newOptions: SelectOption<string, string>[] = [];
|
||||
|
||||
const isAggregatorExist = columnName
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase());
|
||||
|
||||
const isAggregatorChosen = aggregator === columnName;
|
||||
|
||||
if (isAggregatorExist || aggregator === '') {
|
||||
newOptions = aggregatorOptions;
|
||||
}
|
||||
|
||||
if ((isAggregatorChosen && op === '') || op) {
|
||||
const filteredOperators = HAVING_OPERATORS.filter((num) =>
|
||||
num.toLowerCase().includes(op.toLowerCase()),
|
||||
);
|
||||
|
||||
newOptions = filteredOperators.map((opt) => ({
|
||||
label: `${columnName} ${opt} ${restValue && restValue.join(' ')}`,
|
||||
value: `${columnName} ${opt} ${restValue && restValue.join(' ')}`,
|
||||
}));
|
||||
}
|
||||
|
||||
setOptions(newOptions);
|
||||
},
|
||||
[columnName, aggregatorOptions],
|
||||
);
|
||||
|
||||
const handleSearch = useCallback(
|
||||
(search: string): void => {
|
||||
const trimmedSearch = search.replace(/\s\s+/g, ' ').trimStart();
|
||||
|
||||
const currentSearch = isMulti
|
||||
? trimmedSearch
|
||||
: trimmedSearch.split(' ').slice(0, 3).join(' ');
|
||||
|
||||
const isValidSearch = isValidHavingValue(currentSearch);
|
||||
|
||||
if (isValidSearch) {
|
||||
setSearchText(currentSearch);
|
||||
}
|
||||
},
|
||||
[isMulti],
|
||||
);
|
||||
|
||||
const resetChanges = useCallback((): void => {
|
||||
setSearchText('');
|
||||
setCurrentFormValue(initialHavingValues);
|
||||
setOptions(aggregatorOptions);
|
||||
}, [aggregatorOptions]);
|
||||
|
||||
const handleChange = useCallback(
|
||||
(values: string[]): void => {
|
||||
const having: Having[] = values.map(transformFromStringToHaving);
|
||||
|
||||
const isSelectable =
|
||||
currentFormValue.value.length > 0 &&
|
||||
currentFormValue.value.every((value) => !!value);
|
||||
|
||||
if (isSelectable) {
|
||||
onChange(having);
|
||||
resetChanges();
|
||||
}
|
||||
},
|
||||
[currentFormValue, resetChanges, onChange],
|
||||
);
|
||||
|
||||
const handleUpdateTag = useCallback(
|
||||
(value: string) => {
|
||||
const filteredValues = localValues.filter(
|
||||
(currentValue) => currentValue !== value,
|
||||
);
|
||||
const having: Having[] = filteredValues.map(transformFromStringToHaving);
|
||||
|
||||
onChange(having);
|
||||
setSearchText(value);
|
||||
},
|
||||
[localValues, onChange],
|
||||
);
|
||||
|
||||
const tagRender = useCallback(
|
||||
({ label, value, closable, disabled, onClose }: HavingTagRenderProps) => {
|
||||
const handleClose = (): void => {
|
||||
onClose();
|
||||
setSearchText('');
|
||||
};
|
||||
return (
|
||||
<HavingFilterTag
|
||||
label={label}
|
||||
value={value}
|
||||
closable={closable}
|
||||
disabled={disabled}
|
||||
onClose={handleClose}
|
||||
onUpdate={handleUpdateTag}
|
||||
/>
|
||||
);
|
||||
},
|
||||
[handleUpdateTag],
|
||||
);
|
||||
|
||||
const handleSelect = (currentValue: string): void => {
|
||||
const { columnName, op, value } = getHavingObject(currentValue);
|
||||
|
||||
const isCompletedValue = value.every((item) => !!item);
|
||||
|
||||
const isClearSearch = isCompletedValue && columnName && op;
|
||||
|
||||
setSearchText(isClearSearch ? '' : currentValue);
|
||||
};
|
||||
|
||||
const parseSearchText = useCallback(
|
||||
(text: string) => {
|
||||
const { columnName, op, value } = getHavingObject(text);
|
||||
setCurrentFormValue({ columnName, op, value });
|
||||
|
||||
generateOptions(text);
|
||||
},
|
||||
[generateOptions],
|
||||
);
|
||||
|
||||
const handleDeselect = (value: string): void => {
|
||||
const result = localValues.filter((item) => item !== value);
|
||||
const having: Having[] = result.map(transformFromStringToHaving);
|
||||
onChange(having);
|
||||
resetChanges();
|
||||
};
|
||||
|
||||
const handleFocus = useCallback(() => {
|
||||
setErrorMessage(null);
|
||||
}, []);
|
||||
|
||||
const handleBlur = useCallback((): void => {
|
||||
if (searchText) {
|
||||
const { columnName, op, value } = getHavingObject(searchText);
|
||||
const isCompleteHavingClause =
|
||||
columnName && op && value.every((v) => v !== '');
|
||||
|
||||
if (isCompleteHavingClause && isValidHavingValue(searchText)) {
|
||||
setLocalValues((prev) => {
|
||||
const updatedValues = [...prev, searchText];
|
||||
onChange(updatedValues.map(transformFromStringToHaving));
|
||||
return updatedValues;
|
||||
});
|
||||
setSearchText('');
|
||||
} else {
|
||||
setErrorMessage('Invalid HAVING clause');
|
||||
}
|
||||
}
|
||||
}, [searchText, onChange]);
|
||||
|
||||
useEffect(() => {
|
||||
parseSearchText(searchText);
|
||||
}, [searchText, parseSearchText]);
|
||||
|
||||
useEffect(() => {
|
||||
setLocalValues(transformHavingToStringValue(having as Having[]));
|
||||
}, [having]);
|
||||
|
||||
const isMetricsDataSource = query.dataSource === DataSource.METRICS;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Select
|
||||
getPopupContainer={getPopupContainer}
|
||||
autoClearSearchValue={false}
|
||||
mode="multiple"
|
||||
onSearch={handleSearch}
|
||||
searchValue={searchText}
|
||||
tagRender={tagRender}
|
||||
value={localValues}
|
||||
data-testid="havingSelect"
|
||||
disabled={isMetricsDataSource && !query.aggregateAttribute?.key}
|
||||
style={{ width: '100%' }}
|
||||
notFoundContent={currentFormValue.value.length === 0 ? undefined : null}
|
||||
placeholder="GroupBy(operation) > 5"
|
||||
onDeselect={handleDeselect}
|
||||
onChange={handleChange}
|
||||
onSelect={handleSelect}
|
||||
onFocus={handleFocus}
|
||||
onBlur={handleBlur}
|
||||
status={errorMessage ? 'error' : undefined}
|
||||
>
|
||||
{options.map((opt) => (
|
||||
<Select.Option key={opt.value} value={opt.value} title="havingOption">
|
||||
{opt.label}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
{errorMessage && (
|
||||
<div style={{ color: Color.BG_CHERRY_500 }}>{errorMessage}</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||
// Constants
|
||||
import {
|
||||
HAVING_OPERATORS,
|
||||
initialQueryBuilderFormValuesMap,
|
||||
} from 'constants/queryBuilder';
|
||||
import { transformFromStringToHaving } from 'lib/query/transformQueryBuilderData';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
// ** Types
|
||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
// ** Components
|
||||
import { HavingFilter } from '../HavingFilter';
|
||||
|
||||
const valueWithAttributeAndOperator: IBuilderQuery = {
|
||||
...initialQueryBuilderFormValuesMap.logs,
|
||||
aggregateOperator: 'SUM',
|
||||
aggregateAttribute: {
|
||||
key: 'bytes',
|
||||
type: 'tag',
|
||||
dataType: DataTypes.Float64,
|
||||
},
|
||||
};
|
||||
|
||||
describe('Having filter behaviour', () => {
|
||||
it('Having filter render is rendered', () => {
|
||||
const mockFn = jest.fn();
|
||||
const { unmount } = render(
|
||||
<HavingFilter
|
||||
query={initialQueryBuilderFormValuesMap.metrics}
|
||||
onChange={mockFn}
|
||||
entityVersion={DEFAULT_ENTITY_VERSION}
|
||||
/>,
|
||||
);
|
||||
|
||||
const selectId = 'havingSelect';
|
||||
|
||||
const select = screen.getByTestId(selectId);
|
||||
|
||||
expect(select).toBeInTheDocument();
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('Having render is disabled initially', () => {
|
||||
const mockFn = jest.fn();
|
||||
const { unmount } = render(
|
||||
<HavingFilter
|
||||
query={initialQueryBuilderFormValuesMap.metrics}
|
||||
onChange={mockFn}
|
||||
entityVersion={DEFAULT_ENTITY_VERSION}
|
||||
/>,
|
||||
);
|
||||
|
||||
const input = screen.getByRole('combobox');
|
||||
|
||||
expect(input).toBeDisabled();
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('Is having filter is enable', () => {
|
||||
const mockFn = jest.fn();
|
||||
const { unmount } = render(
|
||||
<HavingFilter
|
||||
query={valueWithAttributeAndOperator}
|
||||
onChange={mockFn}
|
||||
entityVersion={DEFAULT_ENTITY_VERSION}
|
||||
/>,
|
||||
);
|
||||
|
||||
const input = screen.getByRole('combobox');
|
||||
|
||||
expect(input).toBeEnabled();
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('Autocomplete in the having filter', async () => {
|
||||
const onChange = jest.fn();
|
||||
const user = userEvent.setup();
|
||||
|
||||
const constructedAttribute = 'SUM(bytes)';
|
||||
const optionTestTitle = 'havingOption';
|
||||
|
||||
const { unmount } = render(
|
||||
<HavingFilter
|
||||
query={valueWithAttributeAndOperator}
|
||||
onChange={onChange}
|
||||
entityVersion={DEFAULT_ENTITY_VERSION}
|
||||
/>,
|
||||
);
|
||||
|
||||
// get input
|
||||
const input = screen.getByRole('combobox');
|
||||
|
||||
// click on the select
|
||||
await user.click(input);
|
||||
|
||||
// show predefined options for operator with attribute SUM(bytes)
|
||||
const option = screen.getByTitle(optionTestTitle);
|
||||
|
||||
expect(option).toBeInTheDocument();
|
||||
|
||||
await user.click(option);
|
||||
|
||||
// autocomplete input
|
||||
expect(input).toHaveValue(constructedAttribute);
|
||||
|
||||
// clear value from input and write from keyboard
|
||||
await user.clear(input);
|
||||
|
||||
await user.type(input, 'bytes');
|
||||
|
||||
// show again predefined options for operator with attribute SUM(bytes)
|
||||
const sameAttributeOption = screen.getByTitle(optionTestTitle);
|
||||
|
||||
expect(sameAttributeOption).toBeInTheDocument();
|
||||
|
||||
await user.click(sameAttributeOption);
|
||||
|
||||
expect(input).toHaveValue(constructedAttribute);
|
||||
|
||||
// show operators after SUM(bytes)
|
||||
const operatorsOptions = screen.getAllByTitle(optionTestTitle);
|
||||
|
||||
expect(operatorsOptions).toHaveLength(HAVING_OPERATORS.length);
|
||||
|
||||
// show operators after SUM(bytes) when type from keyboard
|
||||
await user.clear(input);
|
||||
|
||||
await user.type(input, `${constructedAttribute} !=`);
|
||||
|
||||
// get filtered operators
|
||||
const filteredOperators = screen.getAllByTitle(optionTestTitle);
|
||||
|
||||
expect(filteredOperators).toHaveLength(1);
|
||||
|
||||
// clear and show again all operators
|
||||
await user.clear(input);
|
||||
await user.type(input, constructedAttribute);
|
||||
|
||||
const returnedOptions = screen.getAllByTitle(optionTestTitle);
|
||||
|
||||
expect(returnedOptions).toHaveLength(HAVING_OPERATORS.length);
|
||||
|
||||
// check write value after operator
|
||||
await user.clear(input);
|
||||
await user.type(input, `${constructedAttribute} != 123`);
|
||||
|
||||
expect(input).toHaveValue(`${constructedAttribute} != 123`);
|
||||
|
||||
const optionWithValue = screen.getByTitle(optionTestTitle);
|
||||
|
||||
// onChange after complete writting in the input or autocomplete
|
||||
await user.click(optionWithValue);
|
||||
|
||||
expect(onChange).toHaveBeenCalledTimes(1);
|
||||
expect(onChange).toHaveBeenCalledWith([
|
||||
transformFromStringToHaving(`${constructedAttribute} != 123`),
|
||||
]);
|
||||
|
||||
// onChange with multiple operator
|
||||
await user.type(input, `${constructedAttribute} IN 123 123`);
|
||||
|
||||
expect(input).toHaveValue(`${constructedAttribute} IN 123 123`);
|
||||
|
||||
const optionWithMultipleValue = screen.getByTitle(optionTestTitle);
|
||||
await user.click(optionWithMultipleValue);
|
||||
|
||||
expect(onChange).toHaveBeenCalledTimes(2);
|
||||
expect(onChange).toHaveBeenCalledWith([
|
||||
transformFromStringToHaving(`${constructedAttribute} IN 123 123`),
|
||||
]);
|
||||
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
export { HavingFilter } from './HavingFilter';
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
MetricsexplorertypesListMetricDTO,
|
||||
MetrictypesTypeDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { ATTRIBUTE_TYPES } from 'constants/queryBuilder';
|
||||
import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
@@ -114,7 +113,6 @@ function MetricQueryHarness({ query }: { query: IBuilderQuery }): JSX.Element {
|
||||
useQueryOperations({
|
||||
query,
|
||||
index: 0,
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -562,7 +560,6 @@ function StatefulMetricQueryHarness({
|
||||
useQueryOperations({
|
||||
query,
|
||||
index: 0,
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
});
|
||||
|
||||
const currentAggregation = query.aggregations?.[0] as MetricAggregation;
|
||||
|
||||
@@ -8,8 +8,6 @@ export type OrderByFilterProps = {
|
||||
query: IBuilderQuery;
|
||||
onChange: (values: OrderByPayload[]) => void;
|
||||
isRawQuery?: boolean;
|
||||
entityVersion?: string;
|
||||
isNewQueryV2?: boolean;
|
||||
placeholder?: string;
|
||||
/** A logs or traces heatmap aggregates a field, which Order by then offers. */
|
||||
panelType?: PANEL_TYPES;
|
||||
|
||||
@@ -20,8 +20,6 @@ export function OrderByFilter({
|
||||
query,
|
||||
onChange,
|
||||
isRawQuery = false,
|
||||
entityVersion,
|
||||
isNewQueryV2 = false,
|
||||
placeholder,
|
||||
panelType,
|
||||
}: OrderByFilterProps): JSX.Element {
|
||||
@@ -29,12 +27,11 @@ export function OrderByFilter({
|
||||
const {
|
||||
debouncedSearchText,
|
||||
selectedValue,
|
||||
aggregationOptions,
|
||||
generateOptions,
|
||||
createOptions,
|
||||
handleChange,
|
||||
handleSearchKeys,
|
||||
} = useOrderByFilter({ query, onChange, entityVersion });
|
||||
} = useOrderByFilter({ query, onChange });
|
||||
|
||||
const builderQueryType = useBuilderQueryType(query);
|
||||
const { data: fieldKeys, isFetching } = useFieldKeysSuggestion(
|
||||
@@ -51,11 +48,10 @@ export function OrderByFilter({
|
||||
},
|
||||
);
|
||||
|
||||
// Get parsed aggregation options using createAggregation only for QueryV2
|
||||
// Get parsed aggregation options using createAggregation
|
||||
const parsedAggregationOptions = useMemo(
|
||||
() =>
|
||||
isNewQueryV2 ? getParsedAggregationOptionsForOrderBy(query, panelType) : [],
|
||||
[query, isNewQueryV2, panelType],
|
||||
() => getParsedAggregationOptionsForOrderBy(query, panelType),
|
||||
[query, panelType],
|
||||
);
|
||||
|
||||
const optionsData = useMemo(() => {
|
||||
@@ -68,10 +64,7 @@ export function OrderByFilter({
|
||||
const options =
|
||||
query.aggregateOperator === MetricAggregateOperator.NOOP
|
||||
? keyOptions
|
||||
: [
|
||||
...groupByOptions,
|
||||
...(isNewQueryV2 ? aggregationOptionsFromParsed : aggregationOptions),
|
||||
];
|
||||
: [...groupByOptions, ...aggregationOptionsFromParsed];
|
||||
|
||||
return generateOptions(options);
|
||||
}, [
|
||||
@@ -80,9 +73,7 @@ export function OrderByFilter({
|
||||
query.groupBy,
|
||||
query.aggregateOperator,
|
||||
parsedAggregationOptions,
|
||||
aggregationOptions,
|
||||
generateOptions,
|
||||
isNewQueryV2,
|
||||
]);
|
||||
|
||||
const isDisabledSelect =
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user