SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
test(query-builder): make suggestion-fetch debounce overridable to deflake CodeMirror spec (#12336)
Aditya Singh5eb3b5e3e0d6
diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx b/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsxindex 776fe4de35..0761e781bd 100644--- a/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx+++ b/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/QuerySearch.tsx@@ -49,7 +49,11 @@ import { unquote } from 'utils/stringUtils';import { getRecentQueries } from 'lib/recentQueries/getRecentQueries';import type { SignalType } from 'types/api/v5/queryRange';-import { queryExamples, SUGGESTIONS_SECTION } from './constants';+import {+ queryExamples,+ SUGGESTION_FETCH_DEBOUNCE_MS,+ SUGGESTIONS_SECTION,+} from './constants';import {combineInitialAndUserExpression,dedupeOptionsByLabel,@@ -353,7 +357,7 @@ function QuerySearch({);const debouncedFetchKeySuggestions = useMemo(- () => debounce(fetchKeySuggestions, 300),+ () => debounce(fetchKeySuggestions, SUGGESTION_FETCH_DEBOUNCE_MS),[fetchKeySuggestions],);@@ -584,7 +588,7 @@ function QuerySearch({);const debouncedFetchValueSuggestions = useMemo(- () => debounce(fetchValueSuggestions, 300),+ () => debounce(fetchValueSuggestions, SUGGESTION_FETCH_DEBOUNCE_MS),[fetchValueSuggestions],);diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/constants.ts b/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/constants.tsindex a07da15eb2..f438afd849 100644--- a/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/constants.ts+++ b/frontend/src/components/QueryBuilderV2/QueryV2/QuerySearch/constants.ts@@ -1,6 +1,8 @@export const RECENTS_SECTION = { name: 'Recent searches', rank: 1 } as const;export const SUGGESTIONS_SECTION = { name: 'Suggestions', rank: 2 } as const;+export const SUGGESTION_FETCH_DEBOUNCE_MS = 300;+// TODO: move to using TelemetrytypesFieldContextDTO when we migrate getKeySuggestions API (Part of https://github.com/SigNoz/engineering-pod/issues/5289)export const FIELD_CONTEXTS = ['attribute',diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/__tests__/QuerySearch.contextSuggestions.test.tsx b/frontend/src/components/QueryBuilderV2/QueryV2/__tests__/QuerySearch.contextSuggestions.test.tsxindex f2452cb2d0..b854db8593 100644--- a/frontend/src/components/QueryBuilderV2/QueryV2/__tests__/QuerySearch.contextSuggestions.test.tsx+++ b/frontend/src/components/QueryBuilderV2/QueryV2/__tests__/QuerySearch.contextSuggestions.test.tsx@@ -23,6 +23,13 @@ jest.mock('providers/Dashboard/store/useDashboardStore', () => ({}),}));+// Shrink the suggestion-fetch debounce (300ms in prod) so these integration+// tests aren't paced by it; coalescing semantics stay intact.+jest.mock('../QuerySearch/constants', () => ({+ ...jest.requireActual('../QuerySearch/constants'),+ SUGGESTION_FETCH_DEBOUNCE_MS: 30,+}));+jest.mock('hooks/queryBuilder/useQueryBuilder', () => {const handleRunQuery = jest.fn();return {