fix: applied debounce for absolute time range (#11465)

Fixes: https://github.com/openobserve/o2-enterprise/issues/1566
This commit is contained in:
Bhargav
2026-04-26 07:30:32 +00:00
committed by GitHub
parent cc466132a7
commit da20b53633
4 changed files with 69 additions and 7 deletions
+3
View File
@@ -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 &&
+35 -7
View File
@@ -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");
}
};
+3
View File
@@ -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
+28
View File
@@ -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",