fix: dont create reports on retries
This commit is contained in:
parent
78bf29453f
commit
de9e3c6ed9
1 changed files with 40 additions and 26 deletions
|
|
@ -956,7 +956,15 @@ impl RustyPipeQuery {
|
||||||
) -> Result<M> {
|
) -> Result<M> {
|
||||||
for n in 0..self.client.inner.n_query_retries.saturating_sub(1) {
|
for n in 0..self.client.inner.n_query_retries.saturating_sub(1) {
|
||||||
let res = self
|
let res = self
|
||||||
._try_execute_request_deobf::<R, M, B>(ctype, operation, id, endpoint, body, deobf)
|
._try_execute_request_deobf::<R, M, B>(
|
||||||
|
ctype,
|
||||||
|
operation,
|
||||||
|
id,
|
||||||
|
endpoint,
|
||||||
|
body,
|
||||||
|
deobf,
|
||||||
|
n == 0,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
let emsg = match res {
|
let emsg = match res {
|
||||||
Ok(res) => return Ok(res),
|
Ok(res) => return Ok(res),
|
||||||
|
|
@ -974,11 +982,14 @@ impl RustyPipeQuery {
|
||||||
|
|
||||||
warn!("{} retry attempt #{}. Error: {}.", operation, n, emsg);
|
warn!("{} retry attempt #{}. Error: {}.", operation, n, emsg);
|
||||||
}
|
}
|
||||||
self._try_execute_request_deobf::<R, M, B>(ctype, operation, id, endpoint, body, deobf)
|
self._try_execute_request_deobf::<R, M, B>(
|
||||||
.await
|
ctype, operation, id, endpoint, body, deobf, false,
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Single try of `execute_request_deobf`
|
/// Single try of `execute_request_deobf`
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn _try_execute_request_deobf<
|
async fn _try_execute_request_deobf<
|
||||||
R: DeserializeOwned + MapResponse<M> + Debug,
|
R: DeserializeOwned + MapResponse<M> + Debug,
|
||||||
M,
|
M,
|
||||||
|
|
@ -991,6 +1002,7 @@ impl RustyPipeQuery {
|
||||||
endpoint: &str,
|
endpoint: &str,
|
||||||
body: &B,
|
body: &B,
|
||||||
deobf: Option<&Deobfuscator>,
|
deobf: Option<&Deobfuscator>,
|
||||||
|
report: bool,
|
||||||
) -> Result<M> {
|
) -> Result<M> {
|
||||||
let request = self
|
let request = self
|
||||||
.request_builder(ctype, endpoint)
|
.request_builder(ctype, endpoint)
|
||||||
|
|
@ -1007,30 +1019,32 @@ impl RustyPipeQuery {
|
||||||
let resp_str = response.text().await?;
|
let resp_str = response.text().await?;
|
||||||
|
|
||||||
let create_report = |level: Level, error: Option<String>, msgs: Vec<String>| {
|
let create_report = |level: Level, error: Option<String>, msgs: Vec<String>| {
|
||||||
if let Some(reporter) = &self.client.inner.reporter {
|
if report {
|
||||||
let report = Report {
|
if let Some(reporter) = &self.client.inner.reporter {
|
||||||
info: Default::default(),
|
let report = Report {
|
||||||
level,
|
info: Default::default(),
|
||||||
operation: format!("{}({})", operation, id),
|
level,
|
||||||
error,
|
operation: format!("{}({})", operation, id),
|
||||||
msgs,
|
error,
|
||||||
deobf_data: deobf.map(Deobfuscator::get_data),
|
msgs,
|
||||||
http_request: crate::report::HTTPRequest {
|
deobf_data: deobf.map(Deobfuscator::get_data),
|
||||||
url: request_url,
|
http_request: crate::report::HTTPRequest {
|
||||||
method: "POST".to_string(),
|
url: request_url,
|
||||||
req_header: request_headers
|
method: "POST".to_string(),
|
||||||
.iter()
|
req_header: request_headers
|
||||||
.map(|(k, v)| {
|
.iter()
|
||||||
(k.to_string(), v.to_str().unwrap_or_default().to_owned())
|
.map(|(k, v)| {
|
||||||
})
|
(k.to_string(), v.to_str().unwrap_or_default().to_owned())
|
||||||
.collect(),
|
})
|
||||||
req_body: serde_json::to_string(body).unwrap_or_default(),
|
.collect(),
|
||||||
status: status.into(),
|
req_body: serde_json::to_string(body).unwrap_or_default(),
|
||||||
resp_body: resp_str.to_owned(),
|
status: status.into(),
|
||||||
},
|
resp_body: resp_str.to_owned(),
|
||||||
};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
reporter.report(&report);
|
reporter.report(&report);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue