File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ pub struct ApiEvent {
38
38
response : Option < serde_json:: Value > ,
39
39
#[ serde( flatten) ]
40
40
event_type : ApiEventsType ,
41
+ hs_latency : Option < u128 > ,
41
42
}
42
43
43
44
impl ApiEvent {
@@ -49,6 +50,7 @@ impl ApiEvent {
49
50
status_code : i64 ,
50
51
request : serde_json:: Value ,
51
52
response : Option < serde_json:: Value > ,
53
+ hs_latency : Option < u128 > ,
52
54
auth_type : AuthenticationType ,
53
55
event_type : ApiEventsType ,
54
56
http_req : & HttpRequest ,
@@ -72,6 +74,7 @@ impl ApiEvent {
72
74
. and_then ( |user_agent_value| user_agent_value. to_str ( ) . ok ( ) . map ( ToOwned :: to_owned) ) ,
73
75
url_path : http_req. path ( ) . to_string ( ) ,
74
76
event_type,
77
+ hs_latency,
75
78
}
76
79
}
77
80
}
Original file line number Diff line number Diff line change @@ -830,6 +830,7 @@ where
830
830
. as_millis ( ) ;
831
831
832
832
let mut serialized_response = None ;
833
+ let mut overhead_latency = None ;
833
834
let status_code = match output. as_ref ( ) {
834
835
Ok ( res) => {
835
836
if let ApplicationResponse :: Json ( data) = res {
@@ -839,6 +840,19 @@ where
839
840
. attach_printable ( "Failed to serialize json response" )
840
841
. change_context ( errors:: ApiErrorResponse :: InternalServerError . switch ( ) ) ?,
841
842
) ;
843
+ } else if let ApplicationResponse :: JsonWithHeaders ( ( data, headers) ) = res {
844
+ serialized_response. replace (
845
+ masking:: masked_serialize ( & data)
846
+ . into_report ( )
847
+ . attach_printable ( "Failed to serialize json response" )
848
+ . change_context ( errors:: ApiErrorResponse :: InternalServerError . switch ( ) ) ?,
849
+ ) ;
850
+
851
+ if let Some ( ( _, value) ) = headers. iter ( ) . find ( |( key, _) | key == X_HS_LATENCY ) {
852
+ if let Ok ( external_latency) = value. parse :: < u128 > ( ) {
853
+ overhead_latency. replace ( external_latency) ;
854
+ }
855
+ }
842
856
}
843
857
event_type = res. get_api_event_type ( ) . or ( event_type) ;
844
858
@@ -854,6 +868,7 @@ where
854
868
status_code,
855
869
serialized_request,
856
870
serialized_response,
871
+ overhead_latency,
857
872
auth_type,
858
873
event_type. unwrap_or ( ApiEventsType :: Miscellaneous ) ,
859
874
request,
You can’t perform that action at this time.
0 commit comments