@@ -2,14 +2,15 @@ use anyhow::{Context, Result};
22use axum:: { body:: Body , response:: Response } ;
33use futures_util:: StreamExt ;
44use rivet_api_builder:: { ApiCtx , ErrorResponse , RawErrorResponse } ;
5- use serde:: { Serialize , de:: DeserializeOwned } ;
5+ use serde:: { de:: DeserializeOwned , Serialize } ;
66use std:: future:: Future ;
77
88mod errors;
99
1010pub use axum:: http:: { HeaderMap , Method } ;
1111
1212/// Generic function to make raw requests to remote datacenters by label (returns axum Response)
13+ #[ tracing:: instrument( skip( ctx, headers, query, body) ) ]
1314pub async fn request_remote_datacenter_raw (
1415 ctx : & ApiCtx ,
1516 dc_label : u16 ,
@@ -32,6 +33,8 @@ pub async fn request_remote_datacenter_raw(
3233 url. set_query ( Some ( & serde_html_form:: to_string ( q) ?) ) ;
3334 }
3435
36+ tracing:: debug!( %method, %url, "sending raw request to remote datacenter" ) ;
37+
3538 let mut request = client. request ( method, url) . headers ( headers) ;
3639
3740 if let Some ( b) = body {
@@ -48,6 +51,7 @@ pub async fn request_remote_datacenter_raw(
4851}
4952
5053/// Generic function to make requests to a specific datacenter
54+ #[ tracing:: instrument( skip( config, headers, query, body) ) ]
5155pub async fn request_remote_datacenter < T > (
5256 config : & rivet_config:: Config ,
5357 dc_label : u16 ,
7276 url. set_query ( Some ( & serde_html_form:: to_string ( q) ?) ) ;
7377 }
7478
79+ tracing:: debug!( %method, %url, "sending request to remote datacenter" ) ;
80+
7581 let mut request = client. request ( method, url) . headers ( headers) ;
7682
7783 if let Some ( b) = body {
8995
9096/// Generic function to fanout requests to all datacenters and aggregate results
9197/// Returns aggregated results and errors only if all requests fail
98+ #[ tracing:: instrument( skip( ctx, headers, query, local_handler, aggregator) ) ]
9299pub async fn fanout_to_datacenters < I , Q , F , Fut , A , R > (
93100 ctx : ApiCtx ,
94101 headers : HeaderMap ,
@@ -164,6 +171,7 @@ where
164171 Ok ( aggregated)
165172}
166173
174+ #[ tracing:: instrument( skip_all) ]
167175pub async fn reqwest_to_axum_response ( reqwest_response : reqwest:: Response ) -> Result < Response > {
168176 let status = reqwest_response. status ( ) ;
169177 let headers = reqwest_response. headers ( ) . clone ( ) ;
@@ -178,6 +186,7 @@ pub async fn reqwest_to_axum_response(reqwest_response: reqwest::Response) -> Re
178186 Ok ( response)
179187}
180188
189+ #[ tracing:: instrument( skip_all) ]
181190pub async fn parse_response < T : DeserializeOwned > ( reqwest_response : reqwest:: Response ) -> Result < T > {
182191 let status = reqwest_response. status ( ) ;
183192 let response_text = reqwest_response. text ( ) . await ?;
0 commit comments