Skip to content

Commit a45d1da

Browse files
committed
record in pipeline + test moved
Signed-off-by: Maayan Shani <[email protected]>
1 parent af95644 commit a45d1da

File tree

3 files changed

+293
-18
lines changed

3 files changed

+293
-18
lines changed

glide-core/redis-rs/redis/src/cluster_async/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,13 @@ impl<C> Future for Request<C> {
920920
Next::Done.into()
921921
}
922922
Err((target, err)) => {
923+
println!("Request error: {:?}", err);
924+
923925
let request = this.request.as_mut().unwrap();
926+
print!(
927+
"Retry {}, max {}",
928+
request.retry, this.retry_params.number_of_retries
929+
);
924930
// TODO - would be nice if we didn't need to repeat this code twice, with & without retries.
925931
if request.retry >= this.retry_params.number_of_retries {
926932
let retry_method = err.retry_method();

glide-core/redis-rs/redis/src/cluster_async/pipeline_routing.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub(crate) type ResponsePoliciesMap =
9797
/// Adds a command to the pipeline map for a specific node address.
9898
///
9999
/// `add_asking` is a boolean flag that determines whether to add an `ASKING` command before the command.
100+
/// `is_retrying` is a boolean flag that indicates whether this is a retry attempt.
100101
fn add_command_to_node_pipeline_map<C>(
101102
pipeline_map: &mut NodePipelineMap<C>,
102103
address: String,
@@ -105,9 +106,19 @@ fn add_command_to_node_pipeline_map<C>(
105106
index: usize,
106107
inner_index: Option<usize>,
107108
add_asking: bool,
109+
is_retrying: bool,
108110
) where
109111
C: Clone,
110112
{
113+
if is_retrying {
114+
// Record retry attempt metric if telemetry is initialized
115+
if let Err(e) = GlideOpenTelemetry::record_retries() {
116+
log_error(
117+
"OpenTelemetry:retry_error",
118+
format!("Failed to record retry attempt: {}", e),
119+
);
120+
}
121+
}
111122
if add_asking {
112123
let asking_cmd = Arc::new(crate::cmd::cmd("ASKING"));
113124
pipeline_map
@@ -226,6 +237,7 @@ where
226237
index,
227238
Some(inner_index),
228239
false,
240+
false,
229241
);
230242
}
231243
}
@@ -281,7 +293,7 @@ where
281293
.await
282294
.map_err(|err| (OperationTarget::NotFound, err))?;
283295

284-
add_command_to_node_pipeline_map(pipeline_map, address, conn, cmd, index, None, false);
296+
add_command_to_node_pipeline_map(pipeline_map, address, conn, cmd, index, None, false, false);
285297
Ok(())
286298
}
287299

@@ -326,6 +338,7 @@ where
326338
index,
327339
Some(inner_index),
328340
false,
341+
false,
329342
);
330343
} else {
331344
return Err((
@@ -1089,6 +1102,7 @@ where
10891102
index,
10901103
inner_index,
10911104
matches!(retry_method, RetryMethod::AskRedirect),
1105+
true,
10921106
);
10931107
continue;
10941108
}
@@ -1204,15 +1218,9 @@ where
12041218
index,
12051219
inner_index,
12061220
false,
1221+
true,
12071222
);
12081223

1209-
// Record retry attempt metric if telemetry is initialized
1210-
if let Err(e) = GlideOpenTelemetry::record_retries() {
1211-
log_error(
1212-
"OpenTelemetry:retry_error",
1213-
format!("Failed to record retry attempt: {}", e),
1214-
);
1215-
}
12161224
}
12171225
Err(redis_error) => {
12181226
error.append_detail(&redis_error.into());

0 commit comments

Comments
 (0)