mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-17 23:47:12 +00:00
chore: removed traceoperations and reused queryoperations
This commit is contained in:
parent
561ec8fd40
commit
eba024fc5d
@ -51,6 +51,8 @@ import {
|
|||||||
export const MAX_FORMULAS = 20;
|
export const MAX_FORMULAS = 20;
|
||||||
export const MAX_QUERIES = 26;
|
export const MAX_QUERIES = 26;
|
||||||
|
|
||||||
|
export const TRACE_OPERATOR_QUERY_NAME = 'T1';
|
||||||
|
|
||||||
export const idDivider = '--';
|
export const idDivider = '--';
|
||||||
export const selectValueDivider = '__';
|
export const selectValueDivider = '__';
|
||||||
|
|
||||||
@ -267,28 +269,8 @@ export const initialFormulaBuilderFormValues: IBuilderFormula = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const initialQueryBuilderFormTraceOperatorValues: IBuilderTraceOperator = {
|
export const initialQueryBuilderFormTraceOperatorValues: IBuilderTraceOperator = {
|
||||||
queryName: 'T1',
|
...initialQueryBuilderFormTracesValues,
|
||||||
legend: '',
|
queryName: TRACE_OPERATOR_QUERY_NAME,
|
||||||
expression: '',
|
|
||||||
limit: null,
|
|
||||||
orderBy: [],
|
|
||||||
aggregateOperator: MeterAggregateOperator.COUNT,
|
|
||||||
aggregateAttribute: initialAutocompleteData,
|
|
||||||
timeAggregation: MeterAggregateOperator.RATE,
|
|
||||||
spaceAggregation: MeterAggregateOperator.SUM,
|
|
||||||
aggregations: [
|
|
||||||
{
|
|
||||||
metricName: '',
|
|
||||||
temporality: '',
|
|
||||||
timeAggregation: MeterAggregateOperator.COUNT,
|
|
||||||
spaceAggregation: MeterAggregateOperator.SUM,
|
|
||||||
reduceTo: 'avg',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
stepInterval: undefined,
|
|
||||||
having: [],
|
|
||||||
groupBy: [],
|
|
||||||
reduceTo: 'avg',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initialQueryPromQLData: IPromQLQuery = {
|
export const initialQueryPromQLData: IPromQLQuery = {
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
import {
|
|
||||||
HandleChangeTraceOperatorData,
|
|
||||||
UseTraceOperatorOperations,
|
|
||||||
} from 'types/common/operations.types';
|
|
||||||
import { useQueryBuilder } from './useQueryBuilder';
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
import { LEGEND } from 'constants/global';
|
|
||||||
import { getFormatedLegend } from 'utils/getFormatedLegend';
|
|
||||||
|
|
||||||
export const useTraceOperatorOperations: UseTraceOperatorOperations = ({
|
|
||||||
index = 0,
|
|
||||||
query,
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
handleSetTraceOperatorData,
|
|
||||||
addTraceOperator,
|
|
||||||
currentQuery,
|
|
||||||
} = useQueryBuilder();
|
|
||||||
|
|
||||||
const handleChangeTraceOperatorData: HandleChangeTraceOperatorData = useCallback(
|
|
||||||
(key, value) => {
|
|
||||||
if (!query) {
|
|
||||||
addTraceOperator('');
|
|
||||||
}
|
|
||||||
const updatedQuery = query
|
|
||||||
? query
|
|
||||||
: currentQuery.builder.queryTraceOperator[0];
|
|
||||||
|
|
||||||
const newQuery = {
|
|
||||||
...updatedQuery,
|
|
||||||
[key]:
|
|
||||||
key === LEGEND && typeof value === 'string'
|
|
||||||
? getFormatedLegend(value)
|
|
||||||
: value,
|
|
||||||
};
|
|
||||||
|
|
||||||
handleSetTraceOperatorData(index, newQuery);
|
|
||||||
},
|
|
||||||
[handleSetTraceOperatorData, index, query],
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
handleChangeTraceOperatorData,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@ -15,6 +15,7 @@ import {
|
|||||||
MAX_FORMULAS,
|
MAX_FORMULAS,
|
||||||
MAX_QUERIES,
|
MAX_QUERIES,
|
||||||
PANEL_TYPES,
|
PANEL_TYPES,
|
||||||
|
TRACE_OPERATOR_QUERY_NAME,
|
||||||
} from 'constants/queryBuilder';
|
} from 'constants/queryBuilder';
|
||||||
import ROUTES from 'constants/routes';
|
import ROUTES from 'constants/routes';
|
||||||
import {
|
import {
|
||||||
@ -651,12 +652,12 @@ export function QueryBuilderProvider({
|
|||||||
const trimmed = (expression || '').trim();
|
const trimmed = (expression || '').trim();
|
||||||
|
|
||||||
setCurrentQuery((prevState) => {
|
setCurrentQuery((prevState) => {
|
||||||
const existing = prevState.builder.queryTraceOperator[0];
|
const existing = prevState.builder.queryTraceOperator?.[0] || null;
|
||||||
const updated: IBuilderTraceOperator = existing
|
const updated: IBuilderTraceOperator = existing
|
||||||
? { ...existing, expression: trimmed }
|
? { ...existing, expression: trimmed }
|
||||||
: {
|
: {
|
||||||
...initialQueryBuilderFormTraceOperatorValues,
|
...initialQueryBuilderFormTraceOperatorValues,
|
||||||
queryName: 'T1',
|
queryName: TRACE_OPERATOR_QUERY_NAME,
|
||||||
expression: trimmed,
|
expression: trimmed,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -671,12 +672,12 @@ export function QueryBuilderProvider({
|
|||||||
});
|
});
|
||||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||||
setSupersetQuery((prevState) => {
|
setSupersetQuery((prevState) => {
|
||||||
const existing = prevState.builder.queryTraceOperator[0];
|
const existing = prevState.builder.queryTraceOperator?.[0] || null;
|
||||||
const updated: IBuilderTraceOperator = existing
|
const updated: IBuilderTraceOperator = existing
|
||||||
? { ...existing, expression: trimmed }
|
? { ...existing, expression: trimmed }
|
||||||
: {
|
: {
|
||||||
...initialQueryBuilderFormTraceOperatorValues,
|
...initialQueryBuilderFormTraceOperatorValues,
|
||||||
queryName: 'T1',
|
queryName: TRACE_OPERATOR_QUERY_NAME,
|
||||||
expression: trimmed,
|
expression: trimmed,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -29,10 +29,7 @@ export interface IBuilderFormula {
|
|||||||
orderBy?: OrderByPayload[];
|
orderBy?: OrderByPayload[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IBuilderTraceOperator = Omit<
|
export type IBuilderTraceOperator = IBuilderQuery & {
|
||||||
IBuilderQuery,
|
|
||||||
'dataSource' | 'filter' | 'filters' | 'disabled' | 'functions'
|
|
||||||
> & {
|
|
||||||
returnSpansFrom?: string;
|
returnSpansFrom?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import { SelectOption } from './select';
|
|||||||
|
|
||||||
type UseQueryOperationsParams = Pick<QueryProps, 'index' | 'query'> &
|
type UseQueryOperationsParams = Pick<QueryProps, 'index' | 'query'> &
|
||||||
Pick<QueryBuilderProps, 'filterConfigs'> & {
|
Pick<QueryBuilderProps, 'filterConfigs'> & {
|
||||||
|
isForTraceOperator?: boolean;
|
||||||
formula?: IBuilderFormula;
|
formula?: IBuilderFormula;
|
||||||
isListViewPanel?: boolean;
|
isListViewPanel?: boolean;
|
||||||
entityVersion: string;
|
entityVersion: string;
|
||||||
@ -75,10 +76,3 @@ export type UseQueryOperations = (
|
|||||||
handleQueryFunctionsUpdates: (functions: QueryFunction[]) => void;
|
handleQueryFunctionsUpdates: (functions: QueryFunction[]) => void;
|
||||||
listOfAdditionalFormulaFilters: string[];
|
listOfAdditionalFormulaFilters: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UseTraceOperatorOperations = (params: {
|
|
||||||
index?: number;
|
|
||||||
query?: IBuilderTraceOperator;
|
|
||||||
}) => {
|
|
||||||
handleChangeTraceOperatorData: HandleChangeTraceOperatorData;
|
|
||||||
};
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user