diff --git a/internal/core/src/exec/operator/RescoresNode.cpp b/internal/core/src/exec/operator/RescoresNode.cpp index 87f22f8f92..437f6391ba 100644 --- a/internal/core/src/exec/operator/RescoresNode.cpp +++ b/internal/core/src/exec/operator/RescoresNode.cpp @@ -54,6 +54,10 @@ PhyRescoresNode::GetOutput() { if (input_ == nullptr) { return nullptr; } + + std::chrono::high_resolution_clock::time_point scalar_start = + std::chrono::high_resolution_clock::now(); + ExecContext* exec_context = operator_context_->get_exec_context(); auto query_context_ = exec_context->get_query_context(); auto query_info = exec_context->get_query_config(); @@ -142,6 +146,13 @@ PhyRescoresNode::GetOutput() { bool large_is_better = PositivelyRelated(metric_type); sort_search_result(search_result, large_is_better); query_context_->set_search_result(std::move(search_result)); + + std::chrono::high_resolution_clock::time_point scalar_end = + std::chrono::high_resolution_clock::now(); + double scalar_cost = + std::chrono::duration(scalar_end - scalar_start) + .count(); + monitor::internal_core_search_latency_rescore.Observe(scalar_cost / 1000); return input_; }; diff --git a/internal/core/src/monitor/Monitor.cpp b/internal/core/src/monitor/Monitor.cpp index d75a9d21c7..8a8a3b2deb 100644 --- a/internal/core/src/monitor/Monitor.cpp +++ b/internal/core/src/monitor/Monitor.cpp @@ -163,6 +163,8 @@ std::map groupbyLatencyLabels{ {"type", "groupby_latency"}}; std::map iterativeFilterLatencyLabels{ {"type", "iterative_filter_latency"}}; +std::map rescoreLatencyLabels{ + {"type", "rescore_latency"}}; std::map scalarProportionLabels{ {"type", "scalar_proportion"}}; std::map getVectorLatencyLabels{ @@ -192,6 +194,9 @@ DEFINE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_groupby, DEFINE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_iterative_filter, internal_core_search_latency, iterativeFilterLatencyLabels) +DEFINE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_rescore, + internal_core_search_latency, + rescoreLatencyLabels) DEFINE_PROMETHEUS_HISTOGRAM_WITH_BUCKETS( internal_core_search_latency_scalar_proportion, internal_core_search_latency, diff --git a/internal/core/src/monitor/Monitor.h b/internal/core/src/monitor/Monitor.h index 1655ed631d..b4c3f96890 100644 --- a/internal/core/src/monitor/Monitor.h +++ b/internal/core/src/monitor/Monitor.h @@ -72,6 +72,7 @@ DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_scalar); DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_vector); DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_groupby); DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_iterative_filter); +DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_rescore); DECLARE_PROMETHEUS_HISTOGRAM(internal_core_search_latency_scalar_proportion); DECLARE_PROMETHEUS_HISTOGRAM(internal_core_get_vector_latency); DECLARE_PROMETHEUS_HISTOGRAM(internal_core_retrieve_get_target_entry_latency);