refactor: bring metrics to http output (#3247)

* refactor: bring metrics to http output

* chore: remove unwrap

* chore: make walk plan accumulate

* chore: change field name and comment

* chore: add metrics to http resp header

* chore: move PrometheusJsonResponse to a separate file and impl IntoResponse

* chore: put metrics in prometheus resp header too
This commit is contained in:
shuiyisong
2024-02-20 11:25:18 +08:00
committed by GitHub
parent 6628c41c36
commit bf5e1905cd
58 changed files with 592 additions and 395 deletions

View File

@@ -69,7 +69,7 @@ async fn run_compiled(script: &PyScript) {
.await
.unwrap();
let _res = match output {
Output::Stream(s) => common_recordbatch::util::collect_batches(s).await.unwrap(),
Output::Stream(s, _) => common_recordbatch::util::collect_batches(s).await.unwrap(),
Output::RecordBatches(rbs) => rbs,
_ => unreachable!(),
};

View File

@@ -312,7 +312,7 @@ impl Script for PyScript {
.context(DatabaseQuerySnafu)?;
let copr = self.copr.clone();
match res {
Output::Stream(stream) => Ok(Output::Stream(Box::pin(CoprStream::try_new(
Output::Stream(stream, _) => Ok(Output::new_stream(Box::pin(CoprStream::try_new(
stream, copr, params, ctx,
)?))),
_ => unreachable!(),
@@ -411,7 +411,7 @@ def test(number) -> vector[u32]:
.await
.unwrap();
let res = common_recordbatch::util::collect_batches(match output {
Output::Stream(s) => s,
Output::Stream(s, _) => s,
_ => unreachable!(),
})
.await
@@ -472,7 +472,7 @@ def test(number) -> vector[u32]:
.await
.unwrap();
let res = common_recordbatch::util::collect_batches(match _output {
Output::Stream(s) => s,
Output::Stream(s, _) => s,
_ => todo!(),
})
.await
@@ -504,7 +504,7 @@ def test(a, b, c) -> vector[f64]:
.await
.unwrap();
match output {
Output::Stream(stream) => {
Output::Stream(stream, _) => {
let numbers = util::collect(stream).await.unwrap();
assert_eq!(1, numbers.len());
@@ -542,7 +542,7 @@ def test(a) -> vector[i64]:
.await
.unwrap();
match output {
Output::Stream(stream) => {
Output::Stream(stream, _) => {
let numbers = util::collect(stream).await.unwrap();
assert_eq!(1, numbers.len());

View File

@@ -403,7 +403,7 @@ impl PyQueryEngine {
Ok(Either::AffectedRows(cnt))
}
Ok(common_query::Output::RecordBatches(rbs)) => Ok(Either::Rb(rbs)),
Ok(common_query::Output::Stream(s)) => Ok(Either::Rb(
Ok(common_query::Output::Stream(s, _)) => Ok(Either::Rb(
common_recordbatch::util::collect_batches(s).await.unwrap(),
)),
Err(e) => Err(e),

View File

@@ -88,7 +88,7 @@ async fn integrated_py_copr_test() {
.await
.unwrap();
let res = match output {
Output::Stream(s) => common_recordbatch::util::collect_batches(s).await.unwrap(),
Output::Stream(s, _) => common_recordbatch::util::collect_batches(s).await.unwrap(),
Output::RecordBatches(rbs) => rbs,
_ => unreachable!(),
};

View File

@@ -231,7 +231,7 @@ impl<E: ErrorExt + Send + Sync + 'static> ScriptsTable<E> {
.await
.context(ExecuteInternalStatementSnafu)?;
let stream = match output {
Output::Stream(stream) => stream,
Output::Stream(stream, _) => stream,
Output::RecordBatches(record_batches) => record_batches.as_stream(),
_ => unreachable!(),
};
@@ -286,7 +286,7 @@ impl<E: ErrorExt + Send + Sync + 'static> ScriptsTable<E> {
.await
.context(ExecuteInternalStatementSnafu)?;
let stream = match output {
Output::Stream(stream) => stream,
Output::Stream(stream, _) => stream,
Output::RecordBatches(record_batches) => record_batches.as_stream(),
_ => unreachable!(),
};