mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-17 15:36:48 +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_QUERIES = 26;
|
||||
|
||||
export const TRACE_OPERATOR_QUERY_NAME = 'T1';
|
||||
|
||||
export const idDivider = '--';
|
||||
export const selectValueDivider = '__';
|
||||
|
||||
@ -267,28 +269,8 @@ export const initialFormulaBuilderFormValues: IBuilderFormula = {
|
||||
};
|
||||
|
||||
export const initialQueryBuilderFormTraceOperatorValues: IBuilderTraceOperator = {
|
||||
queryName: 'T1',
|
||||
legend: '',
|
||||
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',
|
||||
...initialQueryBuilderFormTracesValues,
|
||||
queryName: TRACE_OPERATOR_QUERY_NAME,
|
||||
};
|
||||
|
||||
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_QUERIES,
|
||||
PANEL_TYPES,
|
||||
TRACE_OPERATOR_QUERY_NAME,
|
||||
} from 'constants/queryBuilder';
|
||||
import ROUTES from 'constants/routes';
|
||||
import {
|
||||
@ -651,12 +652,12 @@ export function QueryBuilderProvider({
|
||||
const trimmed = (expression || '').trim();
|
||||
|
||||
setCurrentQuery((prevState) => {
|
||||
const existing = prevState.builder.queryTraceOperator[0];
|
||||
const existing = prevState.builder.queryTraceOperator?.[0] || null;
|
||||
const updated: IBuilderTraceOperator = existing
|
||||
? { ...existing, expression: trimmed }
|
||||
: {
|
||||
...initialQueryBuilderFormTraceOperatorValues,
|
||||
queryName: 'T1',
|
||||
queryName: TRACE_OPERATOR_QUERY_NAME,
|
||||
expression: trimmed,
|
||||
};
|
||||
|
||||
@ -671,12 +672,12 @@ export function QueryBuilderProvider({
|
||||
});
|
||||
// eslint-disable-next-line sonarjs/no-identical-functions
|
||||
setSupersetQuery((prevState) => {
|
||||
const existing = prevState.builder.queryTraceOperator[0];
|
||||
const existing = prevState.builder.queryTraceOperator?.[0] || null;
|
||||
const updated: IBuilderTraceOperator = existing
|
||||
? { ...existing, expression: trimmed }
|
||||
: {
|
||||
...initialQueryBuilderFormTraceOperatorValues,
|
||||
queryName: 'T1',
|
||||
queryName: TRACE_OPERATOR_QUERY_NAME,
|
||||
expression: trimmed,
|
||||
};
|
||||
|
||||
|
||||
@ -29,10 +29,7 @@ export interface IBuilderFormula {
|
||||
orderBy?: OrderByPayload[];
|
||||
}
|
||||
|
||||
export type IBuilderTraceOperator = Omit<
|
||||
IBuilderQuery,
|
||||
'dataSource' | 'filter' | 'filters' | 'disabled' | 'functions'
|
||||
> & {
|
||||
export type IBuilderTraceOperator = IBuilderQuery & {
|
||||
returnSpansFrom?: string;
|
||||
};
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ import { SelectOption } from './select';
|
||||
|
||||
type UseQueryOperationsParams = Pick<QueryProps, 'index' | 'query'> &
|
||||
Pick<QueryBuilderProps, 'filterConfigs'> & {
|
||||
isForTraceOperator?: boolean;
|
||||
formula?: IBuilderFormula;
|
||||
isListViewPanel?: boolean;
|
||||
entityVersion: string;
|
||||
@ -75,10 +76,3 @@ export type UseQueryOperations = (
|
||||
handleQueryFunctionsUpdates: (functions: QueryFunction[]) => void;
|
||||
listOfAdditionalFormulaFilters: string[];
|
||||
};
|
||||
|
||||
export type UseTraceOperatorOperations = (params: {
|
||||
index?: number;
|
||||
query?: IBuilderTraceOperator;
|
||||
}) => {
|
||||
handleChangeTraceOperatorData: HandleChangeTraceOperatorData;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user