@@ -773,11 +773,11 @@ fn build_span_tags(
773
773
tags. push ( Key :: new ( ERROR ) . bool ( true ) . into ( ) ) ;
774
774
}
775
775
if !user_overrides. status_code {
776
- tags . push (
777
- Key :: new ( OTEL_STATUS_CODE )
778
- . string :: < & ' static str > ( status_code . as_str ( ) )
779
- . into ( ) ,
780
- ) ;
776
+ if status_code == StatusCode :: Ok {
777
+ tags . push ( KeyValue :: new ( OTEL_STATUS_CODE , "OK" ) . into ( ) ) ;
778
+ } else if status_code == StatusCode :: Error {
779
+ tags . push ( KeyValue :: new ( OTEL_STATUS_CODE , "ERROR" ) . into ( ) ) ;
780
+ }
781
781
}
782
782
// set status message if there is one
783
783
if !status_description. is_empty ( ) && !user_overrides. status_description {
@@ -1057,7 +1057,7 @@ mod tests {
1057
1057
let user_status_description = "Something bad happened" ;
1058
1058
attributes. insert ( KeyValue :: new ( "error" , user_error) ) ;
1059
1059
attributes. insert ( KeyValue :: new ( SPAN_KIND , user_kind) ) ;
1060
- attributes. insert ( KeyValue :: new ( OTEL_STATUS_CODE , user_status_code . as_str ( ) ) ) ;
1060
+ attributes. insert ( KeyValue :: new ( OTEL_STATUS_CODE , "ERROR" ) ) ;
1061
1061
attributes. insert ( KeyValue :: new (
1062
1062
OTEL_STATUS_DESCRIPTION ,
1063
1063
user_status_description,
@@ -1075,7 +1075,7 @@ mod tests {
1075
1075
. filter( |tag| tag. key. as_str( ) == "error" )
1076
1076
. all( |tag| tag. v_bool. unwrap( ) ) ) ;
1077
1077
assert_tag_contains ( tags. clone ( ) , SPAN_KIND , user_kind) ;
1078
- assert_tag_contains ( tags. clone ( ) , OTEL_STATUS_CODE , user_status_code . as_str ( ) ) ;
1078
+ assert_tag_contains ( tags. clone ( ) , OTEL_STATUS_CODE , "ERROR" ) ;
1079
1079
assert_tag_contains ( tags, OTEL_STATUS_DESCRIPTION , user_status_description) ;
1080
1080
}
1081
1081
0 commit comments