charlesdong1991 commented on code in PR #407:
URL: https://github.com/apache/fluss-rust/pull/407#discussion_r2907796689
##########
crates/fluss/src/rpc/server_connection.rs:
##########
@@ -217,6 +218,89 @@ struct ActiveRequest {
channel: Sender<Result<Response, RpcError>>,
}
+/// Tracks per-request connection metrics and ensures in-flight gauge cleanup
on drop.
+struct RequestMetricsLifecycle {
+ label: Option<&'static str>,
+ start: Instant,
+ completed: bool,
+}
+
+impl RequestMetricsLifecycle {
+ fn begin(api_key: crate::rpc::ApiKey, request_bytes: u64) -> Self {
+ let label = crate::metrics::api_key_label(api_key);
+ if let Some(label) = label {
+ // Match Java semantics: count request attempts before write/send.
+ metrics::counter!(
+ crate::metrics::CLIENT_REQUESTS_TOTAL,
+ crate::metrics::LABEL_API_KEY => label
+ )
+ .increment(1);
+ metrics::counter!(
+ crate::metrics::CLIENT_BYTES_SENT_TOTAL,
+ crate::metrics::LABEL_API_KEY => label
+ )
+ .increment(request_bytes);
+ metrics::gauge!(
+ crate::metrics::CLIENT_REQUESTS_IN_FLIGHT,
+ crate::metrics::LABEL_API_KEY => label
+ )
+ .increment(1.0);
+ }
+ Self {
+ label,
+ start: Instant::now(),
+ completed: false,
+ }
Review Comment:
it matches java behaviour now as it captures start time at inflight creation
regardless of reportability.
also not sure if it is an big issue honestly?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]