chore: allow unlimited return if timerange is applied (#7222)

Signed-off-by: shuiyisong <xixing.sys@gmail.com>
This commit is contained in:
shuiyisong
2025-11-12 18:00:11 +08:00
committed by GitHub
parent 8153068b89
commit e842d401fb
3 changed files with 17 additions and 2 deletions

View File

@@ -128,6 +128,7 @@ impl JaegerQueryHandler for Instance {
trace_id: &str,
start_time: Option<i64>,
end_time: Option<i64>,
limit: Option<usize>,
) -> ServerResult<Output> {
// It's equivalent to the following SQL query:
//
@@ -155,6 +156,13 @@ impl JaegerQueryHandler for Instance {
filters.push(col(TIMESTAMP_COLUMN).lt_eq(lit_timestamp_nano(end_time)));
}
let limit = if start_time.is_some() && end_time.is_some() {
// allow unlimited limit if time range is specified
limit
} else {
limit.or(Some(DEFAULT_LIMIT))
};
Ok(query_trace_table(
ctx,
self.catalog_manager(),
@@ -162,7 +170,7 @@ impl JaegerQueryHandler for Instance {
selects,
filters,
vec![col(TIMESTAMP_COLUMN).sort(false, false)], // Sort by timestamp in descending order.
Some(DEFAULT_LIMIT),
limit,
None,
vec![],
)

View File

@@ -427,7 +427,13 @@ pub async fn handle_get_trace(
let end_time_ns = query_params.end.map(|end_us| end_us * 1000);
let output = match handler
.get_trace(query_ctx, &trace_id, start_time_ns, end_time_ns)
.get_trace(
query_ctx,
&trace_id,
start_time_ns,
end_time_ns,
query_params.limit,
)
.await
{
Ok(output) => output,

View File

@@ -210,6 +210,7 @@ pub trait JaegerQueryHandler {
trace_id: &str,
start_time: Option<i64>,
end_time: Option<i64>,
limit: Option<usize>,
) -> Result<Output>;
/// Find traces by query params. It's used for `/api/traces` API.