Skip to content

Commit

Permalink
fix: sort unstable HTTP result in label values query (GreptimeTeam#3920)
Browse files Browse the repository at this point in the history
* fix: sort unstable HTTP result in label values query

Signed-off-by: Ruihang Xia <[email protected]>

* chore: Update src/servers/src/http/prometheus.rs

---------

Signed-off-by: Ruihang Xia <[email protected]>
Co-authored-by: Yingwen <[email protected]>
  • Loading branch information
waynexia and evenyag authored May 11, 2024
1 parent 27e376e commit 590aedd
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/servers/src/http/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,9 @@ pub async fn label_values_query(
);
}
};

return PrometheusJsonResponse::success(PrometheusResponse::LabelValues(
field_columns.into_iter().collect(),
));
let mut field_columns = field_columns.into_iter().collect::<Vec<_>>();
field_columns.sort_unstable();
return PrometheusJsonResponse::success(PrometheusResponse::LabelValues(field_columns));
}

let queries = params.matches.0;
Expand Down Expand Up @@ -754,14 +753,7 @@ pub async fn label_values_query(
.collect();

let mut label_values: Vec<_> = label_values.into_iter().collect();

// sort result for consistent output in tests
#[cfg(test)]
{
label_values.sort_unstable();
}

label_values.sort();
label_values.sort_unstable();
let mut resp = PrometheusJsonResponse::success(PrometheusResponse::LabelValues(label_values));
resp.resp_metrics = merge_map;
resp
Expand Down

0 comments on commit 590aedd

Please sign in to comment.