mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-29 03:30:40 +00:00
Compare commits
8 Commits
perf/uplot
...
chore/qbv5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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);
|
||||
}
|
||||
};
|
||||
@@ -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,7 +430,6 @@ function QueryAddOns({
|
||||
</Tooltip>
|
||||
<div className="input">
|
||||
<OrderByFilter
|
||||
entityVersion={version}
|
||||
query={query}
|
||||
onChange={handleChangeOrderByKeys}
|
||||
isRawQuery={isRawQuery}
|
||||
|
||||
@@ -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,8 +190,7 @@ 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)
|
||||
@@ -265,7 +261,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 +312,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 +321,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;
|
||||
|
||||
@@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 @@ 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
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,6 @@ function TimeSeriesViewContainer({
|
||||
dataSource,
|
||||
},
|
||||
},
|
||||
// ENTITY_VERSION_V4,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { LIVE_TAIL_GRAPH_INTERVAL } from 'constants/liveTail';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import LogsExplorerChart from 'container/LogsExplorerChart';
|
||||
@@ -57,7 +57,7 @@ function LiveLogsListChart({
|
||||
const { data, isFetching } = useGetExplorerQueryRange(
|
||||
listChartQuery,
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
DEFAULT_ENTITY_VERSION,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
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,7 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import {
|
||||
getOrderByTimestamp,
|
||||
@@ -131,7 +131,7 @@ export const useContextLogData = ({
|
||||
const { isError, isFetching } = useGetExplorerQueryRange(
|
||||
requestData,
|
||||
PANEL_TYPES.LIST,
|
||||
DEFAULT_ENTITY_VERSION,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
keepPreviousData: true,
|
||||
enabled: !!requestData,
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -109,7 +109,6 @@ function Explorer(): JSX.Element {
|
||||
}}
|
||||
panelType={PANEL_TYPES.TIME_SERIES}
|
||||
showFunctions={false}
|
||||
version="v3"
|
||||
/>
|
||||
|
||||
<div className="explore-content">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -122,7 +122,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 || {},
|
||||
|
||||
@@ -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,7 +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. */
|
||||
|
||||
@@ -20,7 +20,6 @@ export function OrderByFilter({
|
||||
query,
|
||||
onChange,
|
||||
isRawQuery = false,
|
||||
entityVersion,
|
||||
isNewQueryV2 = false,
|
||||
placeholder,
|
||||
panelType,
|
||||
@@ -34,7 +33,7 @@ export function OrderByFilter({
|
||||
createOptions,
|
||||
handleChange,
|
||||
handleSearchKeys,
|
||||
} = useOrderByFilter({ query, onChange, entityVersion });
|
||||
} = useOrderByFilter({ query, onChange });
|
||||
|
||||
const builderQueryType = useBuilderQueryType(query);
|
||||
const { data: fieldKeys, isFetching } = useFieldKeysSuggestion(
|
||||
|
||||
@@ -32,7 +32,6 @@ export type UseOrderByFilterResult = {
|
||||
export const useOrderByFilter = ({
|
||||
query,
|
||||
onChange,
|
||||
entityVersion,
|
||||
}: OrderByFilterProps): UseOrderByFilterResult => {
|
||||
const [searchText, setSearchText] = useState<string>('');
|
||||
|
||||
@@ -61,8 +60,8 @@ export const useOrderByFilter = ({
|
||||
}, [searchText]);
|
||||
|
||||
const selectedValue = useMemo(
|
||||
() => transformToOrderByStringValues(query, entityVersion),
|
||||
[query, entityVersion],
|
||||
() => transformToOrderByStringValues(query),
|
||||
[query],
|
||||
);
|
||||
|
||||
const generateOptions = useCallback(
|
||||
@@ -127,19 +126,19 @@ export const useOrderByFilter = ({
|
||||
const aggregationOptions = useMemo(
|
||||
() => [
|
||||
{
|
||||
label: `${
|
||||
entityVersion === 'v4' ? query.spaceAggregation : query.aggregateOperator
|
||||
}(${query.aggregateAttribute?.key}) ${ORDERBY_FILTERS.ASC}`,
|
||||
label: `${query.aggregateOperator}(${query.aggregateAttribute?.key}) ${
|
||||
ORDERBY_FILTERS.ASC
|
||||
}`,
|
||||
value: `${SIGNOZ_VALUE}${orderByValueDelimiter}${ORDERBY_FILTERS.ASC}`,
|
||||
},
|
||||
{
|
||||
label: `${
|
||||
entityVersion === 'v4' ? query.spaceAggregation : query.aggregateOperator
|
||||
}(${query.aggregateAttribute?.key}) ${ORDERBY_FILTERS.DESC}`,
|
||||
label: `${query.aggregateOperator}(${query.aggregateAttribute?.key}) ${
|
||||
ORDERBY_FILTERS.DESC
|
||||
}`,
|
||||
value: `${SIGNOZ_VALUE}${orderByValueDelimiter}${ORDERBY_FILTERS.DESC}`,
|
||||
},
|
||||
],
|
||||
[query, entityVersion],
|
||||
[query],
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -12,14 +12,13 @@ export const orderByValueDelimiter = '|';
|
||||
|
||||
export const transformToOrderByStringValues = (
|
||||
query: IBuilderQuery,
|
||||
entityVersion?: string,
|
||||
): IOption[] => {
|
||||
const prepareSelectedValue: IOption[] = query.orderBy.map((item) => {
|
||||
if (item.columnName === SIGNOZ_VALUE) {
|
||||
return {
|
||||
label: `${
|
||||
entityVersion === 'v4' ? query.spaceAggregation : query.aggregateOperator
|
||||
}(${query.aggregateAttribute?.key || ''}) ${item.order}`,
|
||||
label: `${query.aggregateOperator}(${
|
||||
query.aggregateAttribute?.key || ''
|
||||
}) ${item.order}`,
|
||||
value: `${item.columnName}${orderByValueDelimiter}${item.order}`,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
export { AggregatorFilter } from './AggregatorFilter';
|
||||
export { BuilderUnitsFilter } from './BuilderUnitsFilter';
|
||||
export { GroupByFilter } from './GroupByFilter';
|
||||
export { HavingFilter } from './HavingFilter';
|
||||
export { MetricNameSelector } from './MetricNameSelector';
|
||||
export { OperatorsSelect } from './OperatorsSelect';
|
||||
export { OrderByFilter } from './OrderByFilter';
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import { OperatorConfigKeys, OPERATORS_CONFIG } from 'constants/queryBuilder';
|
||||
import { HAVING_FILTER_REGEXP } from 'constants/regExp';
|
||||
import { IOption } from 'hooks/useResourceAttribute/types';
|
||||
import uniqWith from 'lodash-es/unionWith';
|
||||
import { parse } from 'papaparse';
|
||||
import {
|
||||
HavingForm,
|
||||
IBuilderQuery,
|
||||
} from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { MetricAggregation } from 'types/api/v5/queryRange';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
@@ -30,23 +26,6 @@ export const handleKeyDownLimitFilter: React.KeyboardEventHandler<
|
||||
}
|
||||
};
|
||||
|
||||
export const getHavingObject = (currentSearch: string): HavingForm => {
|
||||
const textArr = currentSearch.split(' ');
|
||||
const [columnName = '', op = '', ...value] = textArr;
|
||||
|
||||
return { columnName, op, value };
|
||||
};
|
||||
|
||||
export const isValidHavingValue = (search: string): boolean => {
|
||||
const values = getHavingObject(search).value.join(' ');
|
||||
|
||||
if (values) {
|
||||
return HAVING_FILTER_REGEXP.test(values);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
export const getUniqueOrderByValues = (values: IOption[]): IOption[] => {
|
||||
const modifiedValues = values.map((item) => {
|
||||
const match = parse(item.value, { delimiter: orderByValueDelimiter });
|
||||
|
||||
@@ -28,7 +28,6 @@ export type QueryProps = {
|
||||
queryVariant?: 'static' | 'dropdown';
|
||||
isRawQuery?: boolean;
|
||||
showFunctions?: boolean;
|
||||
version: string;
|
||||
showSpanScopeSelector?: boolean;
|
||||
showOnlyWhereClause?: boolean;
|
||||
showTraceOperator?: boolean;
|
||||
|
||||
@@ -16,7 +16,6 @@ function ResourceAttributesFilter(): JSX.Element | null {
|
||||
const { handleChangeQueryData } = useQueryOperations({
|
||||
index: 0,
|
||||
query,
|
||||
entityVersion: '',
|
||||
});
|
||||
|
||||
// initialise tab with default query.
|
||||
|
||||
@@ -21,7 +21,6 @@ function QuerySection(): JSX.Element {
|
||||
showOnlyWhereClause={
|
||||
panelTypes === PANEL_TYPES.LIST || panelTypes === PANEL_TYPES.TRACE
|
||||
}
|
||||
version="v3" // setting this to v3 as we this is rendered in logs explorer
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,6 @@ function FullView({
|
||||
<>
|
||||
<QueryBuilderV2
|
||||
panelType={selectedPanelType}
|
||||
version="v3"
|
||||
isRawQuery={selectedPanelType === PANEL_TYPES.LIST}
|
||||
signalSourceChangeEnabled
|
||||
// filterConfigs={filterConfigs}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { memo, useEffect, useMemo, useRef, useState } from 'react';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import logEvent from 'api/common/logEvent';
|
||||
import { DEFAULT_ENTITY_VERSION, ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { useScrollWidgetIntoView } from 'lib/visualization/hooks/useScrollWidgetIntoView';
|
||||
@@ -171,7 +171,7 @@ function GridCardGraph({
|
||||
end: customTimeRange?.endTime || end,
|
||||
originalGraphType: widget?.panelTypes,
|
||||
},
|
||||
version || DEFAULT_ENTITY_VERSION,
|
||||
version || ENTITY_VERSION_V5,
|
||||
{
|
||||
queryKey: [
|
||||
REACT_QUERY_KEY.DASHBOARD_GRID_CARD_QUERY_RANGE,
|
||||
@@ -290,7 +290,7 @@ GridCardGraph.defaultProps = {
|
||||
isQueryEnabled: true,
|
||||
threshold: undefined,
|
||||
headerMenuList: [MenuItemKeys.View],
|
||||
version: 'v3',
|
||||
version: ENTITY_VERSION_V5,
|
||||
analyticsEvent: undefined,
|
||||
customTimeRangeWindowForCoRelation: undefined,
|
||||
enableDrillDown: false,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { ENTITY_VERSION_V4, ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { ATTRIBUTE_TYPES } from 'constants/queryBuilder';
|
||||
import {
|
||||
BaseAutocompleteData,
|
||||
@@ -85,7 +84,6 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
useQueryOperations({
|
||||
query: defaultMockQuery,
|
||||
index: 0,
|
||||
entityVersion: ENTITY_VERSION_V4,
|
||||
...props,
|
||||
}),
|
||||
);
|
||||
@@ -98,7 +96,7 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
});
|
||||
|
||||
describe('handleChangeAggregatorAttribute', () => {
|
||||
it('should set AVG operators when type is empty but key is present - unkown metric', () => {
|
||||
it('defaults an unknown metric to avg over time and space', () => {
|
||||
const result = renderHookWithProps();
|
||||
const newAttribute: BaseAutocompleteData = {
|
||||
key: 'new_metric',
|
||||
@@ -114,14 +112,19 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
0,
|
||||
expect.objectContaining({
|
||||
aggregateAttribute: newAttribute,
|
||||
aggregateOperator: MetricAggregateOperator.AVG,
|
||||
timeAggregation: MetricAggregateOperator.AVG,
|
||||
spaceAggregation: MetricAggregateOperator.AVG,
|
||||
aggregations: [
|
||||
{
|
||||
timeAggregation: MetricAggregateOperator.AVG,
|
||||
metricName: 'new_metric',
|
||||
temporality: '',
|
||||
spaceAggregation: MetricAggregateOperator.AVG,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should set COUNT/RATE/SUM operators when both type and key are empty', () => {
|
||||
it('defaults a metric with no name or type to avg over time and sum over space', () => {
|
||||
const result = renderHookWithProps();
|
||||
const newAttribute: BaseAutocompleteData = {
|
||||
key: '',
|
||||
@@ -137,15 +140,20 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
0,
|
||||
expect.objectContaining({
|
||||
aggregateAttribute: newAttribute,
|
||||
aggregateOperator: MetricAggregateOperator.COUNT,
|
||||
timeAggregation: MetricAggregateOperator.RATE,
|
||||
spaceAggregation: MetricAggregateOperator.SUM,
|
||||
aggregations: [
|
||||
{
|
||||
timeAggregation: MetricAggregateOperator.AVG,
|
||||
metricName: '',
|
||||
temporality: '',
|
||||
spaceAggregation: MetricAggregateOperator.SUM,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should preserve aggregation operators when metric type remains the same (GAUGE to GAUGE)', () => {
|
||||
const result = renderHookWithProps({ entityVersion: ENTITY_VERSION_V5 });
|
||||
const result = renderHookWithProps();
|
||||
const newAttribute: BaseAutocompleteData = {
|
||||
key: 'new_gauge_metric',
|
||||
dataType: DataTypes.Float64,
|
||||
@@ -173,7 +181,7 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
});
|
||||
|
||||
it('should reset aggregation operators when metric type changes (GAUGE to SUM) with v5 from start', () => {
|
||||
const result = renderHookWithProps({ entityVersion: ENTITY_VERSION_V5 });
|
||||
const result = renderHookWithProps();
|
||||
const newAttribute: BaseAutocompleteData = {
|
||||
key: 'new_sum_metric',
|
||||
dataType: DataTypes.Float64,
|
||||
@@ -222,7 +230,6 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
useQueryOperations({
|
||||
query: sumMockQuery,
|
||||
index: 0,
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -277,7 +284,6 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
useQueryOperations({
|
||||
query,
|
||||
index: 0,
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
}),
|
||||
{
|
||||
initialProps: { query: gaugeQuery },
|
||||
@@ -333,6 +339,44 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('time aggregation options for the metric a query holds', () => {
|
||||
const queryWithMetric = (type: ATTRIBUTE_TYPES): IBuilderQuery => ({
|
||||
...defaultMockQuery,
|
||||
aggregateAttribute: {
|
||||
key: 'held_metric',
|
||||
dataType: DataTypes.Float64,
|
||||
type,
|
||||
} as BaseAutocompleteData,
|
||||
});
|
||||
|
||||
it('offers rate and increase for a sum metric', () => {
|
||||
const result = renderHookWithProps({
|
||||
query: queryWithMetric(ATTRIBUTE_TYPES.SUM),
|
||||
});
|
||||
|
||||
expect(result.current.operators.map((o) => o.value)).toStrictEqual([
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.INCREASE,
|
||||
]);
|
||||
});
|
||||
|
||||
it('offers latest through count distinct for a gauge metric', () => {
|
||||
const result = renderHookWithProps({
|
||||
query: queryWithMetric(ATTRIBUTE_TYPES.GAUGE),
|
||||
});
|
||||
|
||||
expect(result.current.operators.map((o) => o.value)).toStrictEqual([
|
||||
MetricAggregateOperator.LATEST,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.AVG,
|
||||
MetricAggregateOperator.MIN,
|
||||
MetricAggregateOperator.MAX,
|
||||
MetricAggregateOperator.COUNT,
|
||||
MetricAggregateOperator.COUNT_DISTINCT,
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('spaceAggregationOptions for a histogram metric', () => {
|
||||
const histogramQuery: IBuilderQuery = {
|
||||
...defaultMockQuery,
|
||||
@@ -376,7 +420,7 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
};
|
||||
|
||||
it('defaults the spatial aggregation to p90 on a time series panel', () => {
|
||||
const result = renderHookWithProps({ entityVersion: ENTITY_VERSION_V5 });
|
||||
const result = renderHookWithProps();
|
||||
act(() => {
|
||||
result.current.handleChangeAggregatorAttribute(histogramAttribute);
|
||||
});
|
||||
@@ -396,7 +440,7 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
it('defaults it to count on a heatmap panel, which offers nothing else', () => {
|
||||
setupMockQueryBuilder('heatmap');
|
||||
|
||||
const result = renderHookWithProps({ entityVersion: ENTITY_VERSION_V5 });
|
||||
const result = renderHookWithProps();
|
||||
act(() => {
|
||||
result.current.handleChangeAggregatorAttribute(histogramAttribute);
|
||||
});
|
||||
@@ -417,7 +461,6 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
setupMockQueryBuilder('heatmap');
|
||||
|
||||
const result = renderHookWithProps({
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
query: {
|
||||
...defaultMockQuery,
|
||||
bucketOptions: { kind: 'log', spec: { scale: 2 } },
|
||||
@@ -438,7 +481,6 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
it('moves the sort on the old field to the new one', () => {
|
||||
setupMockQueryBuilder('heatmap');
|
||||
const result = renderHookWithProps({
|
||||
entityVersion: ENTITY_VERSION_V5,
|
||||
query: {
|
||||
...defaultMockQuery,
|
||||
dataSource: DataSource.TRACES,
|
||||
@@ -471,7 +513,7 @@ describe('useQueryBuilderOperations - Empty Aggregate Attribute Type', () => {
|
||||
(panelType, expression) => {
|
||||
setupMockQueryBuilder(panelType);
|
||||
|
||||
const result = renderHookWithProps({ entityVersion: ENTITY_VERSION_V5 });
|
||||
const result = renderHookWithProps();
|
||||
act(() => {
|
||||
result.current.handleChangeDataSource(DataSource.TRACES);
|
||||
});
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
||||
import { getAggregateKeys } from 'api/queryBuilder/getAttributeKeys';
|
||||
import { QueryBuilderKeys } from 'constants/queryBuilder';
|
||||
import type { InfraMonitoringEntity } from 'container/InfraMonitoringK8sV2/constants';
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
import { IGetAttributeKeysPayload } from 'types/api/queryBuilder/getAttributeKeys';
|
||||
import { IQueryAutocompleteResponse } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
|
||||
type UseGetAttributeKeys = (
|
||||
requestData: IGetAttributeKeysPayload,
|
||||
options?: UseQueryOptions<
|
||||
SuccessResponse<IQueryAutocompleteResponse> | ErrorResponse
|
||||
>,
|
||||
isInfraMonitoring?: boolean,
|
||||
infraMonitoringEntity?: InfraMonitoringEntity | null,
|
||||
) => UseQueryResult<
|
||||
SuccessResponse<IQueryAutocompleteResponse> | ErrorResponse
|
||||
>;
|
||||
|
||||
export const useGetAggregateKeys: UseGetAttributeKeys = (
|
||||
requestData,
|
||||
options,
|
||||
isInfraMonitoring,
|
||||
infraMonitoringEntity,
|
||||
) => {
|
||||
const queryKey = useMemo(() => {
|
||||
if (options?.queryKey && Array.isArray(options.queryKey)) {
|
||||
return [
|
||||
QueryBuilderKeys.GET_AGGREGATE_KEYS,
|
||||
...options.queryKey,
|
||||
isInfraMonitoring,
|
||||
infraMonitoringEntity,
|
||||
];
|
||||
}
|
||||
return [
|
||||
QueryBuilderKeys.GET_AGGREGATE_KEYS,
|
||||
requestData,
|
||||
isInfraMonitoring,
|
||||
infraMonitoringEntity,
|
||||
];
|
||||
}, [options?.queryKey, requestData, isInfraMonitoring, infraMonitoringEntity]);
|
||||
|
||||
return useQuery<SuccessResponse<IQueryAutocompleteResponse> | ErrorResponse>({
|
||||
queryFn: () => getAggregateKeys(requestData),
|
||||
...options,
|
||||
queryKey,
|
||||
});
|
||||
};
|
||||
@@ -1,33 +0,0 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
||||
import { getAttributesValues } from 'api/queryBuilder/getAttributesValues';
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
import {
|
||||
IAttributeValuesResponse,
|
||||
IGetAttributeValuesPayload,
|
||||
} from 'types/api/queryBuilder/getAttributesValues';
|
||||
|
||||
type UseGetAttributeValues = (
|
||||
requestData: IGetAttributeValuesPayload,
|
||||
options?: UseQueryOptions<
|
||||
SuccessResponse<IAttributeValuesResponse> | ErrorResponse
|
||||
>,
|
||||
) => UseQueryResult<SuccessResponse<IAttributeValuesResponse> | ErrorResponse>;
|
||||
|
||||
export const useGetAggregateValues: UseGetAttributeValues = (
|
||||
requestData,
|
||||
options,
|
||||
) => {
|
||||
const queryKey = useMemo(() => {
|
||||
if (options?.queryKey && Array.isArray(options.queryKey)) {
|
||||
return [...options.queryKey];
|
||||
}
|
||||
return [requestData];
|
||||
}, [options?.queryKey, requestData]);
|
||||
|
||||
return useQuery<SuccessResponse<IAttributeValuesResponse> | ErrorResponse>({
|
||||
queryKey,
|
||||
queryFn: () => getAttributesValues(requestData),
|
||||
...options,
|
||||
});
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
||||
import { getAttributeSuggestions } from 'api/queryBuilder/getAttributeSuggestions';
|
||||
import { QueryBuilderKeys } from 'constants/queryBuilder';
|
||||
import { ErrorResponse, SuccessResponse } from 'types/api';
|
||||
import {
|
||||
IGetAttributeSuggestionsPayload,
|
||||
IGetAttributeSuggestionsSuccessResponse,
|
||||
} from 'types/api/queryBuilder/getAttributeSuggestions';
|
||||
|
||||
type UseGetAttributeSuggestions = (
|
||||
requestData: IGetAttributeSuggestionsPayload,
|
||||
options?: UseQueryOptions<
|
||||
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
||||
>,
|
||||
) => UseQueryResult<
|
||||
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
||||
>;
|
||||
|
||||
export const useGetAttributeSuggestions: UseGetAttributeSuggestions = (
|
||||
requestData,
|
||||
options,
|
||||
) => {
|
||||
const queryKey = useMemo(() => {
|
||||
if (options?.queryKey && Array.isArray(options.queryKey)) {
|
||||
return [QueryBuilderKeys.GET_ATTRIBUTE_SUGGESTIONS, ...options.queryKey];
|
||||
}
|
||||
return [QueryBuilderKeys.GET_ATTRIBUTE_SUGGESTIONS, requestData];
|
||||
}, [options?.queryKey, requestData]);
|
||||
|
||||
return useQuery<
|
||||
SuccessResponse<IGetAttributeSuggestionsSuccessResponse> | ErrorResponse
|
||||
>({
|
||||
queryKey,
|
||||
queryFn: () => getAttributeSuggestions(requestData),
|
||||
...options,
|
||||
});
|
||||
};
|
||||
@@ -1,41 +0,0 @@
|
||||
import { renderHook } from '@testing-library/react';
|
||||
|
||||
import { useIsValidTag } from './useIsValidTag';
|
||||
|
||||
describe('useIsValidTag', () => {
|
||||
it('returns correct validation result for SINGLE_VALUE operator type', () => {
|
||||
const { result } = renderHook(() => useIsValidTag('SINGLE_VALUE', 1));
|
||||
expect(result.current).toBe(true);
|
||||
|
||||
const { result: result2 } = renderHook(() =>
|
||||
useIsValidTag('SINGLE_VALUE', 0),
|
||||
);
|
||||
expect(result2.current).toBe(false);
|
||||
});
|
||||
|
||||
it('returns correct validation result for MULTIPLY_VALUE operator type', () => {
|
||||
const { result } = renderHook(() => useIsValidTag('MULTIPLY_VALUE', 1));
|
||||
expect(result.current).toBe(true);
|
||||
|
||||
const { result: result2 } = renderHook(() =>
|
||||
useIsValidTag('MULTIPLY_VALUE', 0),
|
||||
);
|
||||
expect(result2.current).toBe(false);
|
||||
});
|
||||
|
||||
it('returns correct validation result for NON_VALUE operator type', () => {
|
||||
const { result } = renderHook(() => useIsValidTag('NON_VALUE', 0));
|
||||
expect(result.current).toBe(true);
|
||||
|
||||
const { result: result2 } = renderHook(() => useIsValidTag('NON_VALUE', 1));
|
||||
expect(result2.current).toBe(false);
|
||||
});
|
||||
|
||||
it('returns correct validation result for NOT_VALID operator type', () => {
|
||||
const { result } = renderHook(() => useIsValidTag('NOT_VALID', 1));
|
||||
expect(result.current).toBe(false);
|
||||
|
||||
const { result: result2 } = renderHook(() => useIsValidTag('NOT_VALID', 0));
|
||||
expect(result2.current).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,3 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { OperatorType } from './useOperatorType';
|
||||
|
||||
export const validationMapper: Record<
|
||||
@@ -11,12 +9,3 @@ export const validationMapper: Record<
|
||||
NON_VALUE: (resultLength: number) => resultLength === 0,
|
||||
NOT_VALID: () => false,
|
||||
};
|
||||
|
||||
export const useIsValidTag = (
|
||||
operatorType: OperatorType,
|
||||
resultLength: number,
|
||||
): boolean =>
|
||||
useMemo(
|
||||
() => validationMapper[operatorType]?.(resultLength),
|
||||
[operatorType, resultLength],
|
||||
);
|
||||
|
||||
@@ -35,6 +35,3 @@ export const operatorTypeMapper: Record<string, OperatorType> = {
|
||||
NEXISTS: 'NON_VALUE',
|
||||
NCONTAINS: 'SINGLE_VALUE',
|
||||
};
|
||||
|
||||
export const useOperatorType = (operator: string): OperatorType =>
|
||||
operatorTypeMapper[operator] || 'NOT_VALID';
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
removeKeyFromPreviousQuery,
|
||||
saveAsPreviousQuery,
|
||||
} from 'components/QueryBuilderV2/QueryV2/previousQuery.utils';
|
||||
import { ENTITY_VERSION_V4, ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { getActiveBuilder } from 'lib/query/builderSlot';
|
||||
import { LEGEND } from 'constants/global';
|
||||
import {
|
||||
@@ -66,7 +65,6 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
index,
|
||||
formula,
|
||||
isRawQuery = false,
|
||||
entityVersion,
|
||||
isForTraceOperator = false,
|
||||
savePreviousQuery = false,
|
||||
}) => {
|
||||
@@ -220,48 +218,7 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
aggregateAttribute: value,
|
||||
};
|
||||
|
||||
if (
|
||||
newQuery.dataSource === DataSource.METRICS &&
|
||||
entityVersion === ENTITY_VERSION_V4
|
||||
) {
|
||||
if (newQuery.aggregateAttribute) {
|
||||
handleMetricAggregateAtributeTypes(newQuery.aggregateAttribute);
|
||||
}
|
||||
|
||||
if (!isEditMode) {
|
||||
if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.SUM) {
|
||||
newQuery.aggregateOperator = MetricAggregateOperator.RATE;
|
||||
newQuery.timeAggregation = MetricAggregateOperator.RATE;
|
||||
} else if (newQuery.aggregateAttribute?.type === ATTRIBUTE_TYPES.GAUGE) {
|
||||
newQuery.aggregateOperator = MetricAggregateOperator.AVG;
|
||||
newQuery.timeAggregation = MetricAggregateOperator.AVG;
|
||||
} else {
|
||||
newQuery.timeAggregation = '';
|
||||
}
|
||||
|
||||
newQuery.spaceAggregation = '';
|
||||
|
||||
// Handled query with unknown metric to avoid 400 and 500 errors
|
||||
// With metric value typed and not available then - time - 'avg', space - 'avg'
|
||||
// If not typed - time - 'rate', space - 'sum', op - 'count'
|
||||
if (isEmpty(newQuery.aggregateAttribute?.type)) {
|
||||
if (!isEmpty(newQuery.aggregateAttribute?.key)) {
|
||||
newQuery.aggregateOperator = MetricAggregateOperator.AVG;
|
||||
newQuery.timeAggregation = MetricAggregateOperator.AVG;
|
||||
newQuery.spaceAggregation = MetricAggregateOperator.AVG;
|
||||
} else {
|
||||
newQuery.aggregateOperator = MetricAggregateOperator.COUNT;
|
||||
newQuery.timeAggregation = MetricAggregateOperator.RATE;
|
||||
newQuery.spaceAggregation = MetricAggregateOperator.SUM;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
newQuery.dataSource === DataSource.METRICS &&
|
||||
entityVersion === ENTITY_VERSION_V5
|
||||
) {
|
||||
if (newQuery.dataSource === DataSource.METRICS) {
|
||||
if (newQuery.aggregateAttribute) {
|
||||
handleMetricAggregateAtributeTypes(newQuery.aggregateAttribute);
|
||||
}
|
||||
@@ -402,7 +359,6 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
},
|
||||
[
|
||||
query,
|
||||
entityVersion,
|
||||
handleSetQueryData,
|
||||
index,
|
||||
handleMetricAggregateAtributeTypes,
|
||||
@@ -585,12 +541,7 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
dataSource === DataSource.METRICS &&
|
||||
query &&
|
||||
query.aggregateAttribute &&
|
||||
entityVersion === ENTITY_VERSION_V4
|
||||
) {
|
||||
if (dataSource === DataSource.METRICS && query && query.aggregateAttribute) {
|
||||
handleMetricAggregateAtributeTypes(query.aggregateAttribute);
|
||||
} else {
|
||||
const initialOperators = getOperatorsBySourceAndPanelType({
|
||||
@@ -611,7 +562,6 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
dataSource,
|
||||
initialDataSource,
|
||||
panelType,
|
||||
entityVersion,
|
||||
query,
|
||||
handleMetricAggregateAtributeTypes,
|
||||
]);
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { useMemo } from 'react';
|
||||
import { QUERY_BUILDER_SEARCH_VALUES } from 'constants/queryBuilder';
|
||||
|
||||
import { useIsValidTag } from './useIsValidTag';
|
||||
import { useOperatorType } from './useOperatorType';
|
||||
|
||||
type ITagValidation = {
|
||||
isValidTag: boolean;
|
||||
isExist: boolean;
|
||||
isValidOperator: boolean;
|
||||
isMulti: boolean;
|
||||
};
|
||||
|
||||
export const useTagValidation = (
|
||||
operator: string,
|
||||
result: string[],
|
||||
): ITagValidation => {
|
||||
const operatorType = useOperatorType(operator);
|
||||
const resultLength =
|
||||
operatorType === 'SINGLE_VALUE' ? [result]?.length : result?.length;
|
||||
const isValidTag = useIsValidTag(operatorType, resultLength);
|
||||
|
||||
const { isExist, isValidOperator, isMulti } = useMemo(() => {
|
||||
const isExist = operatorType === QUERY_BUILDER_SEARCH_VALUES.NON;
|
||||
const isValidOperator =
|
||||
operatorType !== QUERY_BUILDER_SEARCH_VALUES.NOT_VALID;
|
||||
const isMulti = operatorType === QUERY_BUILDER_SEARCH_VALUES.MULTIPLY;
|
||||
|
||||
return { isExist, isValidOperator, isMulti };
|
||||
}, [operatorType]);
|
||||
|
||||
return { isValidTag, isExist, isValidOperator, isMulti };
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { useSelector } from 'react-redux';
|
||||
import { DEFAULT_ENTITY_VERSION } from 'constants/app';
|
||||
import { ENTITY_VERSION_V5 } from 'constants/app';
|
||||
import { QueryParams } from 'constants/query';
|
||||
import {
|
||||
initialQueryBuilderFormValues,
|
||||
@@ -141,7 +141,7 @@ export const useLogsData = ({
|
||||
const { data, isFetching } = useGetExplorerQueryRange(
|
||||
requestData,
|
||||
panelType,
|
||||
DEFAULT_ENTITY_VERSION,
|
||||
ENTITY_VERSION_V5,
|
||||
{
|
||||
keepPreviousData: true,
|
||||
enabled: !isLimit && !!requestData,
|
||||
|
||||
@@ -33,14 +33,6 @@ export const convertMetricKeyToTrace = (key: string): string => {
|
||||
return splittedKey.splice(1).join('.');
|
||||
};
|
||||
|
||||
/**
|
||||
* x.y -> resource_x_y
|
||||
*/
|
||||
export const convertTraceKeyToMetric = (key: string): string => {
|
||||
const splittedKey = key.split('.');
|
||||
return `resource_${splittedKey.join('_')}`;
|
||||
};
|
||||
|
||||
export const convertOperatorLabelToMetricOperator = (label: string): string =>
|
||||
OperatorConversions.find((operator) => operator.label === label)
|
||||
?.metricValue || '';
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'lib/monaco/loader';
|
||||
import './ReactI18';
|
||||
|
||||
import 'styles.scss';
|
||||
import 'lib/uPlotStylesheet';
|
||||
|
||||
installTranslationResilience();
|
||||
configureOverlayScrollbars();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// @ts-nocheck
|
||||
|
||||
import { getMetricsQueryRange } from 'api/metrics/getQueryRange';
|
||||
import { createAggregation } from 'api/v5/queryRange/prepareQueryRangePayloadV5';
|
||||
import {
|
||||
convertV5ResponseToLegacy,
|
||||
@@ -18,20 +17,12 @@ import { Pagination } from 'hooks/queryPagination';
|
||||
import { convertNewDataToOld } from 'lib/newQueryBuilder/convertNewDataToOld';
|
||||
import { isEmpty } from 'lodash-es';
|
||||
import { DynamicVariableSuggestion } from 'providers/Dashboard/store/dynamicVariableSuggestions';
|
||||
import { SuccessResponseV2, Warning } from 'types/api';
|
||||
import { MetricQueryRangeSuccessResponse } from 'types/api/metrics/getQueryRange';
|
||||
import { IBuilderQuery, Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import {
|
||||
ExecStats,
|
||||
MetricRangePayloadV5,
|
||||
QueryRangeResponseV5,
|
||||
} from 'types/api/v5/queryRange';
|
||||
import { QueryData } from 'types/api/widgets/getQuery';
|
||||
import { getActiveBuilder, isBuilderQueryType } from 'lib/query/builderSlot';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import { prepareQueryRangePayload } from './prepareQueryRangePayload';
|
||||
|
||||
/**
|
||||
* Validates if metric name is available for METRICS data source
|
||||
*/
|
||||
@@ -184,25 +175,13 @@ export async function GetMetricQueryRange(
|
||||
signal?: AbortSignal,
|
||||
headers?: Record<string, string>,
|
||||
): Promise<MetricQueryRangeSuccessResponse> {
|
||||
let legendMap: Record<string, string>;
|
||||
let response:
|
||||
| MetricQueryRangeSuccessResponse
|
||||
| SuccessResponseV2<MetricRangePayloadV5>;
|
||||
let warning: Warning | undefined;
|
||||
let meta: ExecStats | undefined;
|
||||
// Raw V5 response, kept before it's converted to legacy — powers client-side export.
|
||||
let rawV5Response: QueryRangeResponseV5 | undefined;
|
||||
|
||||
const panelType = props.originalGraphType || props.graphType;
|
||||
|
||||
const finalFormatForWeb =
|
||||
props.formatForWeb || panelType === PANEL_TYPES.TABLE;
|
||||
|
||||
// Validate metric name for METRICS data source before making the API call
|
||||
if (
|
||||
version === ENTITY_VERSION_V5 &&
|
||||
!validateMetricNameForMetricsDataSource(props.query)
|
||||
) {
|
||||
if (!validateMetricNameForMetricsDataSource(props.query)) {
|
||||
// Return empty response to avoid 400 error when metric name is missing
|
||||
return {
|
||||
statusCode: 200,
|
||||
@@ -226,74 +205,55 @@ export async function GetMetricQueryRange(
|
||||
};
|
||||
}
|
||||
|
||||
if (version === ENTITY_VERSION_V5) {
|
||||
const v5Result = prepareQueryRangePayloadV5(props, dynamicVariables);
|
||||
legendMap = v5Result.legendMap;
|
||||
const v5Result = prepareQueryRangePayloadV5(props, dynamicVariables);
|
||||
const { legendMap } = v5Result;
|
||||
|
||||
// atleast one query should be there to make call to v5 api
|
||||
if (v5Result.queryPayload.compositeQuery.queries.length === 0) {
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: 'At least one query is required',
|
||||
payload: {
|
||||
data: {
|
||||
result: [],
|
||||
resultType: '',
|
||||
newResult: {
|
||||
data: {
|
||||
result: [],
|
||||
resultType: '',
|
||||
},
|
||||
// atleast one query should be there to make call to v5 api
|
||||
if (v5Result.queryPayload.compositeQuery.queries.length === 0) {
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: null,
|
||||
message: 'At least one query is required',
|
||||
payload: {
|
||||
data: {
|
||||
result: [],
|
||||
resultType: '',
|
||||
newResult: {
|
||||
data: {
|
||||
result: [],
|
||||
resultType: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
warning: undefined,
|
||||
params: props,
|
||||
warnings: [],
|
||||
};
|
||||
}
|
||||
|
||||
const v5Response = await getQueryRangeV5(
|
||||
v5Result.queryPayload,
|
||||
version,
|
||||
signal,
|
||||
headers,
|
||||
);
|
||||
|
||||
rawV5Response = v5Response.data.data;
|
||||
|
||||
// Convert V5 response to legacy format for components
|
||||
response = convertV5ResponseToLegacy(
|
||||
{
|
||||
payload: v5Response.data,
|
||||
params: v5Result.queryPayload,
|
||||
},
|
||||
legendMap,
|
||||
finalFormatForWeb,
|
||||
);
|
||||
|
||||
warning = response.payload.warning || undefined;
|
||||
meta = response.payload.meta || undefined;
|
||||
} else {
|
||||
const legacyResult = prepareQueryRangePayload(props);
|
||||
legendMap = legacyResult.legendMap;
|
||||
|
||||
response = await getMetricsQueryRange(
|
||||
legacyResult.queryPayload,
|
||||
version || 'v3',
|
||||
signal,
|
||||
headers,
|
||||
);
|
||||
warning: undefined,
|
||||
params: props,
|
||||
warnings: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (response.statusCode >= 400 && version !== ENTITY_VERSION_V5) {
|
||||
let error = `API responded with ${response.statusCode} - ${response.error} status: ${response.message}`;
|
||||
if (response.body && !isEmpty(response.body)) {
|
||||
error = `${error}, errors: ${response.body}`;
|
||||
}
|
||||
throw new Error(error);
|
||||
}
|
||||
const v5Response = await getQueryRangeV5(
|
||||
v5Result.queryPayload,
|
||||
ENTITY_VERSION_V5,
|
||||
signal,
|
||||
headers,
|
||||
);
|
||||
|
||||
// Raw V5 response, kept before it's converted to legacy — powers client-side export.
|
||||
const rawV5Response = v5Response.data.data;
|
||||
|
||||
// Convert V5 response to legacy format for components
|
||||
const response = convertV5ResponseToLegacy(
|
||||
{
|
||||
payload: v5Response.data,
|
||||
params: v5Result.queryPayload,
|
||||
},
|
||||
legendMap,
|
||||
finalFormatForWeb,
|
||||
);
|
||||
|
||||
const warning = response.payload.warning || undefined;
|
||||
const meta = response.payload.meta || undefined;
|
||||
|
||||
if (finalFormatForWeb) {
|
||||
return response;
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
import getStartEndRangeTime from 'lib/getStartEndRangeTime';
|
||||
import getStep from 'lib/getStep';
|
||||
import { mapQueryDataToApi } from 'lib/newQueryBuilder/queryBuilderMappers/mapQueryDataToApi';
|
||||
import store from 'store';
|
||||
import { QueryRangePayload } from 'types/api/metrics/getQueryRange';
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
|
||||
import { GetQueryResultsProps } from './getQueryResults';
|
||||
|
||||
type PrepareQueryRangePayload = {
|
||||
queryPayload: QueryRangePayload;
|
||||
legendMap: Record<string, string>;
|
||||
};
|
||||
|
||||
export const prepareQueryRangePayload = ({
|
||||
query,
|
||||
globalSelectedInterval,
|
||||
graphType,
|
||||
formatForWeb,
|
||||
selectedTime,
|
||||
tableParams,
|
||||
variables = {},
|
||||
params = {},
|
||||
fillGaps = false,
|
||||
start: startTime,
|
||||
end: endTime,
|
||||
}: GetQueryResultsProps): PrepareQueryRangePayload => {
|
||||
let legendMap: Record<string, string> = {};
|
||||
const { allowSelectedIntervalForStepGen, ...restParams } = params;
|
||||
|
||||
const compositeQuery: QueryRangePayload['compositeQuery'] = {
|
||||
queryType: query.queryType,
|
||||
panelType: graphType,
|
||||
fillGaps,
|
||||
};
|
||||
|
||||
switch (query.queryType) {
|
||||
case EQueryType.QUERY_BUILDER: {
|
||||
const { queryData: data, queryFormulas } = query.builder;
|
||||
const currentQueryData = mapQueryDataToApi(data, 'queryName', tableParams);
|
||||
const currentFormulas = mapQueryDataToApi(queryFormulas, 'queryName');
|
||||
|
||||
const builderQueries = {
|
||||
...currentQueryData.data,
|
||||
...currentFormulas.data,
|
||||
};
|
||||
legendMap = {
|
||||
...currentQueryData.newLegendMap,
|
||||
...currentFormulas.newLegendMap,
|
||||
};
|
||||
|
||||
compositeQuery.builderQueries = builderQueries;
|
||||
break;
|
||||
}
|
||||
case EQueryType.CLICKHOUSE: {
|
||||
const chQueries = query[query.queryType].reduce(
|
||||
(acc, query) => {
|
||||
if (!query.query) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
acc[query.name] = query;
|
||||
|
||||
legendMap[query.name] = query.legend;
|
||||
|
||||
return acc;
|
||||
},
|
||||
{} as NonNullable<QueryRangePayload['compositeQuery']['chQueries']>,
|
||||
);
|
||||
|
||||
compositeQuery.chQueries = chQueries;
|
||||
|
||||
break;
|
||||
}
|
||||
case EQueryType.PROM: {
|
||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||
const promQueries = query[query.queryType].reduce(
|
||||
(acc, query) => {
|
||||
if (!query.query) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
acc[query.name] = query;
|
||||
|
||||
legendMap[query.name] = query.legend;
|
||||
|
||||
return acc;
|
||||
},
|
||||
{} as NonNullable<QueryRangePayload['compositeQuery']['promQueries']>,
|
||||
);
|
||||
|
||||
compositeQuery.promQueries = promQueries;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const { start, end } = getStartEndRangeTime({
|
||||
type: selectedTime,
|
||||
interval: globalSelectedInterval,
|
||||
});
|
||||
|
||||
const queryPayload: QueryRangePayload = {
|
||||
start: startTime ? startTime * 1e3 : parseInt(start, 10) * 1e3,
|
||||
end: endTime ? endTime * 1e3 : parseInt(end, 10) * 1e3,
|
||||
step: getStep({
|
||||
start: allowSelectedIntervalForStepGen
|
||||
? start
|
||||
: store.getState().globalTime.minTime,
|
||||
end: allowSelectedIntervalForStepGen
|
||||
? end
|
||||
: store.getState().globalTime.maxTime,
|
||||
inputFormat: 'ns',
|
||||
}),
|
||||
variables,
|
||||
formatForWeb,
|
||||
compositeQuery,
|
||||
...restParams,
|
||||
};
|
||||
|
||||
return { legendMap, queryPayload };
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
import { autocompleteType } from 'constants/queryBuilder';
|
||||
import { SPLIT_FIRST_UNDERSCORE } from 'constants/regExp';
|
||||
|
||||
export const getAutocompleteValueAndType = (str: string): [string, string] => {
|
||||
const [firstValue, secondValue] = str.split(SPLIT_FIRST_UNDERSCORE);
|
||||
|
||||
if (
|
||||
firstValue === autocompleteType.tag ||
|
||||
firstValue === autocompleteType.resource
|
||||
) {
|
||||
return [firstValue, secondValue];
|
||||
}
|
||||
|
||||
return [str, str];
|
||||
};
|
||||
@@ -21,12 +21,9 @@ import {
|
||||
|
||||
// Asks "would saving the current panel change the persisted widget spec?".
|
||||
//
|
||||
// `adjustQueryForV5` is deliberately not reused here: in addition to stripping
|
||||
// the legacy v4 fields, it also resurrects them onto each metric
|
||||
// `aggregations[i]`. That migration step is correct on save but bleeds
|
||||
// asymmetrically across a comparator — the live query still carries the
|
||||
// legacy defaults from `initialQueryBuilderFormValuesMap` while a previously
|
||||
// saved widget had them stripped.
|
||||
// The legacy v4 fields are stripped from both sides: the live query still
|
||||
// carries the legacy defaults from `initialQueryBuilderFormValuesMap` while a
|
||||
// saved widget may lack them.
|
||||
const stripQueryDataForCompare = (
|
||||
queryData: IBuilderQuery,
|
||||
): Record<string, unknown> => {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { OPERATORS } from 'constants/queryBuilder';
|
||||
import { Having } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
export const transformHavingToStringValue = (having: Having[]): string[] => {
|
||||
const result: string[] = having.map((item) => {
|
||||
const operator = Object.entries(OPERATORS).find(([key]) => key === item.op);
|
||||
const value = Array.isArray(item.value) ? item.value.join(', ') : item.value;
|
||||
|
||||
return `${item.columnName} ${operator ? operator[1] : ''} ${value}`;
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export const transformFromStringToHaving = (havingStr: string): Having => {
|
||||
const [columnName, op, ...values] = havingStr.split(' ');
|
||||
|
||||
const operator = Object.entries(OPERATORS).find(([, value]) => value === op);
|
||||
|
||||
const currentValue = values.reduce<number[]>((acc, strNum) => {
|
||||
const num = parseFloat(strNum);
|
||||
if (Number.isNaN(num)) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
return [...acc, num];
|
||||
}, []);
|
||||
|
||||
return {
|
||||
columnName,
|
||||
op: operator ? operator[0] : '',
|
||||
value: currentValue.length > 1 ? currentValue : currentValue[0],
|
||||
};
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
import href from 'uplot/dist/uPlot.min.css?url';
|
||||
|
||||
// Appended to the end of <body> so uPlot's rules win ties over the app's stylesheets.
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = href;
|
||||
document.body.appendChild(link);
|
||||
@@ -1,51 +1,6 @@
|
||||
// Define a standard page size
|
||||
export const PAGE_SIZE = 100;
|
||||
|
||||
export const logsQueryRangeSuccessResponse = {
|
||||
status: 'success',
|
||||
data: {
|
||||
resultType: '',
|
||||
result: [
|
||||
{
|
||||
queryName: 'A',
|
||||
series: null,
|
||||
list: [
|
||||
{
|
||||
timestamp: '2024-02-15T21:20:22Z',
|
||||
data: {
|
||||
attributes_bool: {},
|
||||
attributes_float64: {},
|
||||
attributes_int64: {},
|
||||
attributes_string: {
|
||||
container_id: 'container_id',
|
||||
container_name: 'container_name',
|
||||
driver: 'driver',
|
||||
eta: '2m0s',
|
||||
location: 'frontend',
|
||||
log_level: 'INFO',
|
||||
message: 'Dispatch successful',
|
||||
service: 'frontend',
|
||||
span_id: 'span_id',
|
||||
trace_id: 'span_id',
|
||||
},
|
||||
body:
|
||||
'2024-02-15T21:20:22.035Z INFO frontend Dispatch successful {"service": "frontend", "trace_id": "span_id", "span_id": "span_id", "driver": "driver", "eta": "2m0s"}',
|
||||
id: 'id',
|
||||
resources_string: {
|
||||
'container.name': 'container_name',
|
||||
},
|
||||
severity_number: 0,
|
||||
severity_text: '',
|
||||
span_id: '',
|
||||
trace_flags: 0,
|
||||
trace_id: '',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
export const logsQueryRangeEmptyResponse = {
|
||||
resultType: '',
|
||||
result: [
|
||||
@@ -54,79 +9,3 @@ export const logsQueryRangeEmptyResponse = {
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const logsPaginationQueryRangeSuccessResponse = ({
|
||||
offset = 0,
|
||||
pageSize = PAGE_SIZE,
|
||||
}: {
|
||||
offset?: number;
|
||||
pageSize?: number;
|
||||
}): any => {
|
||||
// Calculate the starting index for this page's items
|
||||
const startIndex = offset;
|
||||
// Determine how many items to generate for *this specific page*
|
||||
// In a real scenario, this might be less than PAGE_SIZE if it's the last page
|
||||
const itemsForThisPage = pageSize;
|
||||
|
||||
return {
|
||||
status: 'success',
|
||||
data: {
|
||||
resultType: '',
|
||||
result: [
|
||||
{
|
||||
queryName: 'A',
|
||||
series: null,
|
||||
// Generate only the items for the current page
|
||||
list: Array.from({ length: itemsForThisPage }, (_, index) => {
|
||||
// Calculate a unique index based on the overall position
|
||||
const cumulativeIndex = startIndex + index;
|
||||
const baseTimestamp = new Date('2024-02-15T21:20:22Z').getTime();
|
||||
// Ensure timestamps decrease for descending order
|
||||
const currentTimestamp = new Date(baseTimestamp - cumulativeIndex * 1000);
|
||||
const timestampString = currentTimestamp.toISOString();
|
||||
// Generate unique IDs based on the cumulative index
|
||||
const id = `id-${cumulativeIndex}`; // Make ID unique across all pages
|
||||
const spanId = `span_id_${cumulativeIndex}`;
|
||||
const traceId = `trace_id_${cumulativeIndex}`;
|
||||
const logLevel = ['INFO', 'WARN', 'ERROR'][cumulativeIndex % 3];
|
||||
const service = ['frontend', 'backend', 'database'][cumulativeIndex % 3];
|
||||
const containerName = `container_name_${cumulativeIndex % 10}`;
|
||||
|
||||
return {
|
||||
timestamp: timestampString,
|
||||
data: {
|
||||
attributes_bool: {},
|
||||
attributes_float64: {},
|
||||
attributes_int64: {},
|
||||
attributes_string: {
|
||||
container_id: `container_id_${cumulativeIndex % 10}`,
|
||||
container_name: containerName,
|
||||
driver: 'driver',
|
||||
eta: `${cumulativeIndex % 5}m${cumulativeIndex % 60}s`,
|
||||
location: service,
|
||||
log_level: logLevel,
|
||||
message: `Log message for item ${cumulativeIndex}`,
|
||||
service,
|
||||
span_id: spanId,
|
||||
trace_id: traceId,
|
||||
},
|
||||
body: `${timestampString} ${logLevel} ${service} Log message for item ${cumulativeIndex} {"service": "${service}", "trace_id": "${traceId}", "span_id": "${spanId}", "driver": "driver", "eta": "${
|
||||
cumulativeIndex % 5
|
||||
}m${cumulativeIndex % 60}s"}`,
|
||||
id,
|
||||
resources_string: {
|
||||
'container.name': containerName,
|
||||
},
|
||||
severity_number: [9, 13, 17][cumulativeIndex % 3],
|
||||
severity_text: logLevel,
|
||||
span_id: spanId,
|
||||
trace_flags: 0,
|
||||
trace_id: traceId,
|
||||
},
|
||||
};
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,83 +1,3 @@
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { QueryRangePayload } from 'types/api/metrics/getQueryRange';
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
|
||||
export const queryRangeSuccessResponse: QueryRangePayload = {
|
||||
status: 'success',
|
||||
data: {
|
||||
resultType: '',
|
||||
result: [
|
||||
{
|
||||
status: 'success',
|
||||
data: {
|
||||
resultType: '',
|
||||
result: [
|
||||
{
|
||||
queryName: 'D',
|
||||
series: [
|
||||
{
|
||||
labels: {
|
||||
service_name: 'Test',
|
||||
},
|
||||
labelsArray: [
|
||||
{
|
||||
service_name: 'Test',
|
||||
},
|
||||
],
|
||||
values: [
|
||||
{
|
||||
timestamp: 1696917600000,
|
||||
value: '0',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
list: null,
|
||||
},
|
||||
{
|
||||
queryName: 'F1',
|
||||
series: null,
|
||||
list: null,
|
||||
},
|
||||
{
|
||||
queryName: 'A',
|
||||
series: [
|
||||
{
|
||||
labels: {
|
||||
service_name: 'Test',
|
||||
},
|
||||
labelsArray: [
|
||||
{
|
||||
service_name: 'Test',
|
||||
},
|
||||
],
|
||||
values: [
|
||||
{
|
||||
timestamp: 1696917600000,
|
||||
value: 'NaN',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
list: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
compositeQuery: {
|
||||
builderQueries: undefined,
|
||||
chQueries: undefined,
|
||||
promQueries: undefined,
|
||||
queryType: EQueryType.QUERY_BUILDER,
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
},
|
||||
end: 0,
|
||||
start: 0,
|
||||
step: 0,
|
||||
};
|
||||
|
||||
export const queryRangeForTimeSeries = {
|
||||
status: 'success',
|
||||
data: {
|
||||
|
||||
@@ -18,20 +18,11 @@ import {
|
||||
getDashboardById,
|
||||
} from './__mockdata__/dashboards';
|
||||
import { licensesSuccessResponse } from './__mockdata__/licenses';
|
||||
import { queryRangeSuccessResponse } from './__mockdata__/query_range';
|
||||
import { serviceSuccessResponse } from './__mockdata__/services';
|
||||
import { topLevelOperationSuccessResponse } from './__mockdata__/top_level_operations';
|
||||
import { traceDetailResponse } from './__mockdata__/tracedetail';
|
||||
|
||||
export const handlers = [
|
||||
rest.post('http://localhost/api/v3/query_range', (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(queryRangeSuccessResponse)),
|
||||
),
|
||||
|
||||
rest.post('http://localhost/api/v4/query_range', (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(queryRangeSuccessResponse)),
|
||||
),
|
||||
|
||||
rest.post('http://localhost/api/v2/services', (req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
@@ -45,102 +36,6 @@ export const handlers = [
|
||||
res(ctx.status(200), ctx.json(topLevelOperationSuccessResponse)),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_keys',
|
||||
(req, res, ctx) => {
|
||||
const metricName = req.url.searchParams.get('metricName');
|
||||
const match = req.url.searchParams.get('match');
|
||||
|
||||
if (metricName === 'signoz_calls_total' && match === 'resource_') {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({ status: 'success', data: ['resource_signoz_collector_id'] }),
|
||||
);
|
||||
}
|
||||
|
||||
return res(ctx.status(500));
|
||||
},
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_values',
|
||||
(req, res, ctx) => {
|
||||
// ?metricName=signoz_calls_total&tagKey=resource_signoz_collector_id
|
||||
const metricName = req.url.searchParams.get('metricName');
|
||||
const tagKey = req.url.searchParams.get('tagKey');
|
||||
|
||||
const attributeKey = req.url.searchParams.get('attributeKey');
|
||||
|
||||
if (attributeKey === 'serviceName') {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
status: 'success',
|
||||
data: {
|
||||
stringAttributeValues: [
|
||||
'customer',
|
||||
'demo-app',
|
||||
'driver',
|
||||
'frontend',
|
||||
'mysql',
|
||||
'redis',
|
||||
'route',
|
||||
'go-grpc-otel-server',
|
||||
'test',
|
||||
],
|
||||
numberAttributeValues: null,
|
||||
boolAttributeValues: null,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (attributeKey === 'name') {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
status: 'success',
|
||||
data: {
|
||||
stringAttributeValues: [
|
||||
'HTTP GET',
|
||||
'HTTP GET /customer',
|
||||
'HTTP GET /dispatch',
|
||||
'HTTP GET /route',
|
||||
],
|
||||
numberAttributeValues: null,
|
||||
boolAttributeValues: null,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
metricName === 'signoz_calls_total' &&
|
||||
tagKey === 'resource_signoz_collector_id'
|
||||
) {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
status: 'success',
|
||||
data: [
|
||||
'f38916c2-daf2-4424-bd3e-4907a7e537b6',
|
||||
'6d4af7f0-4884-4a37-abd4-6bdbee29fa04',
|
||||
'523c44b9-5fe1-46f7-9163-4d2c57ece09b',
|
||||
'aa52e8e8-6f88-4056-8fbd-b377394d022c',
|
||||
'4d515ba2-065d-4856-b2d8-ddb957c44ddb',
|
||||
'fd47a544-1410-4c76-a554-90ef6464da02',
|
||||
'bb455f71-3fe1-4761-bbf5-efe2faee18a6',
|
||||
'48563680-314e-4117-8a6d-1f0389c95e04',
|
||||
'6e866423-7704-4d72-be8b-4695bc36f145',
|
||||
'e4886c76-93f5-430f-9076-eef85524312f',
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return res(ctx.status(500));
|
||||
},
|
||||
),
|
||||
rest.get('http://localhost/api/v2/licenses', (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(licensesSuccessResponse)),
|
||||
),
|
||||
@@ -166,18 +61,6 @@ export const handlers = [
|
||||
),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/aggregate_attributes',
|
||||
(req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
status: 'success',
|
||||
data: { attributeKeys: null },
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
||||
rest.post('http://localhost/api/v1/event', (req, res, ctx) =>
|
||||
res(
|
||||
ctx.status(200),
|
||||
|
||||
@@ -289,31 +289,6 @@ export const apiMonitoringMocks = defineStoryMocks({
|
||||
}),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_keys',
|
||||
response.json((req) => ({
|
||||
status: 'success',
|
||||
data: {
|
||||
attributeKeys: groupByAttributeKeys(
|
||||
req.url.searchParams.get('searchText') ?? '',
|
||||
),
|
||||
},
|
||||
})),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_values',
|
||||
response.json((req) => ({
|
||||
status: 'success',
|
||||
data: {
|
||||
boolAttributeValues: null,
|
||||
numberAttributeValues: null,
|
||||
stringAttributeValues:
|
||||
QUICK_FILTER_VALUES[req.url.searchParams.get('attributeKey') ?? ''] ?? [],
|
||||
},
|
||||
})),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v1/fields/keys',
|
||||
response.json((req) =>
|
||||
|
||||
@@ -117,7 +117,6 @@ function PanelEditorQueryBuilder({
|
||||
EQueryType.QUERY_BUILDER,
|
||||
)}
|
||||
showTraceOperator={!isRawQuery}
|
||||
version="v3"
|
||||
isRawQuery={isRawQuery}
|
||||
signalSourceChangeEnabled
|
||||
savePreviousQuery
|
||||
@@ -148,7 +147,6 @@ function PanelEditorQueryBuilder({
|
||||
panelType={panelType}
|
||||
fieldsConfig={panelDefinition.queryBuilderFields}
|
||||
showTraceOperator={false}
|
||||
version="v3"
|
||||
isRawQuery={isRawQuery}
|
||||
config={{
|
||||
initialDataSource: DataSource.TRACES,
|
||||
|
||||
@@ -28,7 +28,6 @@ import {
|
||||
// same endpoints for the same shapes and answers from the traces builders.
|
||||
import {
|
||||
exportDashboardsResponse,
|
||||
traceAttributeValuesResponse,
|
||||
traceFieldKeysResponse,
|
||||
traceFieldValues,
|
||||
traceQuickFiltersResponse,
|
||||
@@ -130,13 +129,6 @@ export const llmExplorerMocks = defineStoryMocks({
|
||||
),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_values',
|
||||
response.json((req) =>
|
||||
traceAttributeValuesResponse(req.url.searchParams.get('attributeKey')),
|
||||
),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v2/users/me/dashboards',
|
||||
response.json(exportDashboardsResponse),
|
||||
|
||||
@@ -7,9 +7,6 @@ import {
|
||||
} from 'constants/queryBuilder';
|
||||
import { LOCALSTORAGE } from 'constants/localStorage';
|
||||
import { noop } from 'lodash-es';
|
||||
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 { render, screen, userEvent, waitFor } from 'tests/test-utils';
|
||||
@@ -17,8 +14,6 @@ import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import LogsExplorer from '../index';
|
||||
|
||||
const queryRangeURL = 'http://localhost/api/v3/query_range';
|
||||
|
||||
// mocking the graph components in this test as this should be handled separately
|
||||
jest.mock(
|
||||
'container/TimeSeriesView/TimeSeriesView',
|
||||
@@ -94,13 +89,6 @@ jest.mock('providers/preferences/sync/usePreferenceSync', () => ({
|
||||
|
||||
const FREQUENCY_CHART_TOGGLE_TEST_ID = 'logs-frequency-chart-toggle';
|
||||
|
||||
const logsQueryServerRequest = (): void =>
|
||||
server.use(
|
||||
rest.post(queryRangeURL, (req, res, ctx) =>
|
||||
res(ctx.status(200), ctx.json(logsQueryRangeSuccessResponse)),
|
||||
),
|
||||
);
|
||||
|
||||
describe('Logs Explorer Tests', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.removeItem(LOCALSTORAGE.SHOW_FREQUENCY_CHART);
|
||||
@@ -160,8 +148,6 @@ describe('Logs Explorer Tests', () => {
|
||||
|
||||
// update this test properly
|
||||
it.skip('Logs Explorer Page should render with data', async () => {
|
||||
// mocking the query range API to return the logs
|
||||
logsQueryServerRequest();
|
||||
const { queryByText, queryByTestId } = render(
|
||||
<PreferenceContextProvider>
|
||||
<VirtuosoMockContext.Provider
|
||||
@@ -193,8 +179,6 @@ describe('Logs Explorer Tests', () => {
|
||||
});
|
||||
|
||||
it('Multiple Current Queries', async () => {
|
||||
// mocking the query range API to return the logs
|
||||
logsQueryServerRequest();
|
||||
render(
|
||||
<QueryBuilderContext.Provider
|
||||
value={{
|
||||
|
||||
@@ -28,7 +28,6 @@ import type { PageStoryArgs } from '@/storybook/runtime/resolveStory';
|
||||
|
||||
import { logsSavedViewsResponse } from '../../stories/__story_mockdata__/savedViews';
|
||||
import {
|
||||
attributeValuesResponse,
|
||||
dashboardsResponse,
|
||||
infraMetricsResponse,
|
||||
logFieldKeysResponse,
|
||||
@@ -200,16 +199,6 @@ export const liveLogsMocks = defineStoryMocks({
|
||||
),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v3/autocomplete/attribute_values',
|
||||
response.json((req) =>
|
||||
attributeValuesResponse(
|
||||
req.url.searchParams.get('attributeKey') ?? '',
|
||||
req.url.searchParams.get('searchText') ?? '',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
rest.get(
|
||||
'http://localhost/api/v2/saved_views',
|
||||
response.json(() => logsSavedViewsResponse(4)),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user