mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
fix: histogram interval (#4417)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a `histogram_interval` field to enhance query response capabilities, allowing for more detailed data representation. - Enhanced caching logic to set the `histogram_interval` based on the `discard_interval`, improving the handling of cached query responses. - **Improvements** - Added conditional logic in response handling to include `histogram_interval` when specific criteria are met, improving response accuracy and robustness. - Refined checks for empty responses, enhancing the robustness of the merging process for query responses. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -58,6 +58,7 @@ pub struct MultiCachedQueryResponse {
|
||||
pub is_descending: bool,
|
||||
pub limit: i64,
|
||||
pub took: usize,
|
||||
pub histogram_interval: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
Vendored
+3
@@ -143,6 +143,9 @@ pub async fn check_cache(
|
||||
return MultiCachedQueryResponse::default();
|
||||
}
|
||||
let mut multi_resp = MultiCachedQueryResponse::default();
|
||||
if discard_interval > -1 {
|
||||
multi_resp.histogram_interval = discard_interval / 1000 / 1000;
|
||||
}
|
||||
if get_config().common.use_multi_result_cache {
|
||||
let mut multi_res = crate::service::search::cluster::cache_multi::get_cached_results(
|
||||
query_key.to_owned(),
|
||||
|
||||
Vendored
+11
-3
@@ -256,6 +256,9 @@ pub async fn search(
|
||||
res.set_trace_id(trace_id.to_string());
|
||||
res.set_local_took(start.elapsed().as_millis() as usize, ext_took_wait);
|
||||
|
||||
if is_aggregate && c_resp.histogram_interval > -1 {
|
||||
res.histogram_interval = Some(c_resp.histogram_interval);
|
||||
}
|
||||
let req_stats = RequestStats {
|
||||
records: res.hits.len() as i64,
|
||||
response_time: time,
|
||||
@@ -353,14 +356,19 @@ fn merge_response(
|
||||
};
|
||||
|
||||
if cache_response.hits.is_empty()
|
||||
&& search_response.is_empty()
|
||||
&& search_response.first().unwrap().hits.is_empty()
|
||||
&& search_response.last().unwrap().hits.is_empty()
|
||||
&& !search_response.is_empty()
|
||||
&& search_response
|
||||
.first()
|
||||
.map_or(true, |res| res.hits.is_empty())
|
||||
&& search_response
|
||||
.last()
|
||||
.map_or(true, |res| res.hits.is_empty())
|
||||
{
|
||||
for res in search_response {
|
||||
cache_response.total += res.total;
|
||||
cache_response.scan_size += res.scan_size;
|
||||
cache_response.took += res.took;
|
||||
cache_response.histogram_interval = res.histogram_interval;
|
||||
}
|
||||
return cache_response;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user