From da20b53633047fa8d65fd814060bbaddc8fbf53d Mon Sep 17 00:00:00 2001 From: Bhargav Date: Sun, 26 Apr 2026 13:00:32 +0530 Subject: [PATCH] fix: applied debounce for absolute time range (#11465) Fixes: https://github.com/openobserve/o2-enterprise/issues/1566 --- web/src/plugins/logs/Index.vue | 3 ++ web/src/plugins/logs/SearchBar.vue | 42 +++++++++++++++++++++++----- web/src/plugins/traces/Index.vue | 3 ++ web/src/plugins/traces/SearchBar.vue | 28 +++++++++++++++++++ 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/web/src/plugins/logs/Index.vue b/web/src/plugins/logs/Index.vue index 3683a90b9b..ed96354eed 100644 --- a/web/src/plugins/logs/Index.vue +++ b/web/src/plugins/logs/Index.vue @@ -2283,7 +2283,10 @@ export default defineComponent({ // updateDateTime path is NOT already auto-running the query). // Uses runQueryFn so the histogram is also refreshed. const debouncedAutoRunOnDatetime = debounce(() => { + // Absolute time is handled by SearchBar's triggerAbsoluteQueryDebounced (1500ms). + // Only auto-run here for relative time to avoid double-triggering. if ( + searchObj.data.datetime.type === "relative" && searchObj.meta.liveMode && store.state.zoConfig?.auto_query_enabled && store.state.zoConfig?.query_on_stream_selection !== false && diff --git a/web/src/plugins/logs/SearchBar.vue b/web/src/plugins/logs/SearchBar.vue index 3deadc096e..5f25e3c160 100644 --- a/web/src/plugins/logs/SearchBar.vue +++ b/web/src/plugins/logs/SearchBar.vue @@ -3247,6 +3247,32 @@ export default defineComponent({ } }; + // Debounced query trigger for absolute time when auto-run is enabled. + // Gives the user 1.5s to finish typing start/end time before firing. + const triggerAbsoluteQueryDebounced = debounce((value: object) => { + if ( + searchObj.loading == false && + store.state.zoConfig.query_on_stream_selection == false + ) { + searchObj.loading = true; + searchObj.runQuery = true; + } + + if (config.isCloud == "true" && value.userChangedValue) { + segment.track("Button Click", { + button: "Date Change", + tab: value.tab, + value: value, + stream_name: searchObj.data.stream.selectedStream.join(","), + page: "Search Logs", + }); + } + + if (store.state.zoConfig.auto_query_enabled && searchObj.meta.liveMode) { + emit("searchdata"); + } + }, 2500); + const updateDateTime = async (value: object) => { if ( value.valueType == "absolute" && @@ -3303,6 +3329,15 @@ export default defineComponent({ await nextTick(); await nextTick(); + if ( + value.valueType === "absolute" && + store.state.zoConfig.auto_query_enabled + ) { + // Debounce query trigger so user can finish typing the full time value + triggerAbsoluteQueryDebounced(value); + return; + } + if ( searchObj.loading == false && store.state.zoConfig.query_on_stream_selection == false @@ -3328,13 +3363,6 @@ export default defineComponent({ store.state.zoConfig.query_on_stream_selection == false ) { emit("searchdata"); - } else if ( - value.valueType === "absolute" && - store.state.zoConfig.auto_query_enabled && - searchObj.meta.liveMode - ) { - // Live mode: auto-trigger on committed absolute time range change - emit("searchdata"); } }; diff --git a/web/src/plugins/traces/Index.vue b/web/src/plugins/traces/Index.vue index d6aa40acfd..cc1a2d26ae 100644 --- a/web/src/plugins/traces/Index.vue +++ b/web/src/plugins/traces/Index.vue @@ -1892,7 +1892,10 @@ const debouncedAutoRunOnQuery = debounce(() => { // Debounced auto-run on datetime changes in live mode. // Traces has no existing auto-run on datetime, so no guard needed. const debouncedAutoRunOnDatetime = debounce(() => { + // Absolute time is handled by SearchBar's triggerAbsoluteQueryDebounced (2500ms). + // Only auto-run here for relative time to avoid double-triggering. if ( + searchObj.data.datetime.type === "relative" && searchObj.meta.liveMode && store.state.zoConfig?.auto_query_enabled && !searchObj.loading diff --git a/web/src/plugins/traces/SearchBar.vue b/web/src/plugins/traces/SearchBar.vue index 5bd0fd3726..ee237de7b2 100644 --- a/web/src/plugins/traces/SearchBar.vue +++ b/web/src/plugins/traces/SearchBar.vue @@ -411,6 +411,7 @@ import AppTabs from "@/components/common/AppTabs.vue"; import useTraces from "@/composables/useTraces"; import SyntaxGuide from "./SyntaxGuide.vue"; +import { debounce } from "lodash-es"; import segment from "@/services/segment_analytics"; import config from "@/aws-exports"; import useSqlSuggestions from "@/composables/useSuggestions"; @@ -604,6 +605,24 @@ export default defineComponent({ } }; + // Debounced query trigger for absolute time when auto-run is enabled. + // Gives the user 2.5s to finish typing start/end time before firing. + const triggerAbsoluteQueryDebounced = debounce((value: object) => { + if (config.isCloud == "true" && value.userChangedValue) { + segment.track("Button Click", { + button: "Date Change", + tab: value.tab, + value: value, + stream_name: searchObj.data.stream.selectedStream.value, + page: "Search Logs", + }); + } + + if (store.state.zoConfig?.auto_query_enabled && searchObj.meta.liveMode) { + emit("searchdata"); + } + }, 2500); + const updateDateTime = async (value: object) => { if (router.currentRoute.value.name !== "traces") return; if ( @@ -660,6 +679,15 @@ export default defineComponent({ await nextTick(); await nextTick(); + if ( + value.valueType === "absolute" && + store.state.zoConfig?.auto_query_enabled + ) { + // Debounce query trigger so user can finish typing the full time value + triggerAbsoluteQueryDebounced(value); + return; + } + if (config.isCloud == "true" && value.userChangedValue) { segment.track("Button Click", { button: "Date Change",