@@ -70,6 +70,9 @@ pub const STACKS_REQUEST_ID: &str = "X-Request-Id";
70
70
/// from non-Stacks nodes (like Gaia hubs, CDNs, vanilla HTTP servers, and so on).
71
71
pub const HTTP_REQUEST_ID_RESERVED : u32 = 0 ;
72
72
73
+ /// The interval at which to send heartbeat logs
74
+ const HEARTBEAT_INTERVAL : Duration = Duration :: from_secs ( 60 ) ;
75
+
73
76
/// All representations of the `tip=` query parameter value
74
77
#[ derive( Debug , Clone , PartialEq ) ]
75
78
pub enum TipRequest {
@@ -1823,8 +1826,8 @@ pub fn send_http_request(
1823
1826
stream. set_nodelay ( true ) ?;
1824
1827
1825
1828
let start = Instant :: now ( ) ;
1826
-
1827
- debug ! ( "send_request: Sending request" ; "request" => %request . request_path( ) ) ;
1829
+ let request_path = request . request_path ( ) ;
1830
+ debug ! ( "send_request: Sending request" ; "request" => request_path) ;
1828
1831
1829
1832
// Some explanation of what's going on here is in order.
1830
1833
//
@@ -1882,6 +1885,7 @@ pub fn send_http_request(
1882
1885
. map_err ( |e| handle_net_error ( e, "Failed to serialize request body" ) ) ?;
1883
1886
1884
1887
debug ! ( "send_request(sending data)" ) ;
1888
+ let mut last_heartbeat_time = start; // Initialize heartbeat timer for sending loop
1885
1889
loop {
1886
1890
let flushed = request_handle
1887
1891
. try_flush ( )
@@ -1906,12 +1910,21 @@ pub fn send_http_request(
1906
1910
"Timed out while receiving request" ,
1907
1911
) ) ;
1908
1912
}
1913
+ // Heartbeat log
1914
+ if Instant :: now ( ) . saturating_duration_since ( last_heartbeat_time) >= HEARTBEAT_INTERVAL {
1915
+ info ! (
1916
+ "send_request(sending data): heartbeat - still sending request to {} path='{}' (elapsed: {:?})" ,
1917
+ addr, request_path, start. elapsed( )
1918
+ ) ;
1919
+ last_heartbeat_time = Instant :: now ( ) ;
1920
+ }
1909
1921
}
1910
1922
1911
1923
// Step 4: pull bytes from the socket back into the handle, and see if the connection decoded
1912
1924
// and dispatched any new messages to the request handle. If so, then extract the message and
1913
1925
// check that it's a well-formed HTTP response.
1914
1926
debug ! ( "send_request(receiving data)" ) ;
1927
+ last_heartbeat_time = Instant :: now ( ) ;
1915
1928
let response = loop {
1916
1929
// get back the reply
1917
1930
debug ! ( "send_request(receiving data): try to receive data" ) ;
@@ -1950,6 +1963,14 @@ pub fn send_http_request(
1950
1963
"Timed out while receiving request" ,
1951
1964
) ) ;
1952
1965
}
1966
+ // Heartbeat log
1967
+ if Instant :: now ( ) . saturating_duration_since ( last_heartbeat_time) >= HEARTBEAT_INTERVAL {
1968
+ info ! (
1969
+ "send_request(receiving data): heartbeat - still receiving response from {} path='{}' (elapsed: {:?})" ,
1970
+ addr, request_path, start. elapsed( )
1971
+ ) ;
1972
+ last_heartbeat_time = Instant :: now ( ) ;
1973
+ }
1953
1974
} ;
1954
1975
1955
1976
// Step 5: decode the HTTP message and return it if it's not an error.
0 commit comments