@@ -301,6 +301,10 @@ pub struct HttpInfo {
301301
302302 #[ serde( skip_serializing_if = "value_is_default" ) ]
303303 biz_type : u8 ,
304+ #[ serde( skip_serializing_if = "value_is_default" ) ]
305+ biz_code : String ,
306+ #[ serde( skip_serializing_if = "value_is_default" ) ]
307+ biz_scenario : String ,
304308
305309 #[ serde( skip) ]
306310 attributes : Vec < KeyVal > ,
@@ -329,6 +333,14 @@ impl HttpInfo {
329333 || self . msg_type == LogMessageType :: Other
330334 }
331335
336+ // when response_code is overwritten, put it into the attributes.
337+ fn response_code_to_attribute ( & mut self ) {
338+ self . attributes . push ( KeyVal {
339+ key : SYS_RESPONSE_CODE_ATTR . to_string ( ) ,
340+ val : self . status_code . to_string ( ) ,
341+ } ) ;
342+ }
343+
332344 pub fn merge_custom_to_http ( & mut self , custom : CustomInfo , dir : PacketDirection ) {
333345 if dir == PacketDirection :: ClientToServer {
334346 if let Ok ( v) = Version :: try_from ( custom. req . version . as_str ( ) ) {
@@ -358,6 +370,7 @@ impl HttpInfo {
358370
359371 if dir == PacketDirection :: ServerToClient {
360372 if let Some ( code) = custom. resp . code {
373+ self . response_code_to_attribute ( ) ;
361374 self . status_code = code as u16 ;
362375 }
363376
@@ -407,6 +420,12 @@ impl HttpInfo {
407420 if custom. biz_type > 0 {
408421 self . biz_type = custom. biz_type ;
409422 }
423+ if let Some ( biz_code) = custom. biz_code {
424+ self . biz_code = biz_code;
425+ }
426+ if let Some ( biz_scenario) = custom. biz_scenario {
427+ self . biz_scenario = biz_scenario;
428+ }
410429
411430 if let Some ( is_async) = custom. is_async {
412431 self . is_async = is_async;
@@ -436,6 +455,7 @@ impl HttpInfo {
436455 self . stream_id = req_id. parse :: < u32 > ( ) . map_or ( None , Some ) ;
437456 }
438457 if let Some ( resp_code) = tags. remove ( ExtraField :: RESPONSE_CODE ) {
458+ self . response_code_to_attribute ( ) ;
439459 self . status_code = resp_code. parse :: < u16 > ( ) . unwrap_or_default ( ) ;
440460 }
441461
@@ -487,6 +507,16 @@ impl HttpInfo {
487507 * x_req_id = PrioField :: new ( CUSTOM_FIELD_POLICY_PRIORITY , x_request_id)
488508 }
489509 }
510+
511+ if let Some ( biz_type) = tags. remove ( ExtraField :: BIZ_TYPE ) {
512+ self . biz_type = biz_type. parse :: < u8 > ( ) . unwrap_or_default ( ) ;
513+ }
514+ if let Some ( biz_code) = tags. remove ( ExtraField :: BIZ_CODE ) {
515+ self . biz_code = biz_code;
516+ }
517+ if let Some ( biz_scenario) = tags. remove ( ExtraField :: BIZ_SCENARIO ) {
518+ self . biz_scenario = biz_scenario;
519+ }
490520 }
491521}
492522
@@ -639,6 +669,8 @@ impl HttpInfo {
639669 if other. biz_type > 0 {
640670 self . biz_type = other. biz_type ;
641671 }
672+ super :: swap_if!( self , biz_code, is_empty, other) ;
673+ super :: swap_if!( self , biz_scenario, is_empty, other) ;
642674
643675 let other_trace_ids = std:: mem:: take ( & mut other. trace_ids ) ;
644676 self . trace_ids . merge ( other_trace_ids) ;
@@ -844,6 +876,8 @@ impl From<HttpInfo> for L7ProtocolSendLog {
844876 ..Default :: default ( )
845877 } ) ,
846878 flags : flags. bits ( ) ,
879+ biz_code : f. biz_code ,
880+ biz_scenario : f. biz_scenario ,
847881 ..Default :: default ( )
848882 }
849883 }
0 commit comments