@@ -1032,13 +1032,16 @@ private void validateHttpStatusForNonLocalRootWithThrowableForClient(
1032
1032
1033
1033
@ Test
1034
1034
void testDBUserAttribute () {
1035
- String dbUser = "test_user" ;
1036
- mockAttribute (DB_USER , dbUser );
1035
+ mockAttribute (DB_SYSTEM , "db_system" );
1036
+ mockAttribute (DB_OPERATION , "db_operation" );
1037
+ mockAttribute (DB_STATEMENT , "db_statement" );
1038
+ mockAttribute (DB_USER , "db_user" );
1037
1039
when (spanDataMock .getKind ()).thenReturn (SpanKind .CLIENT );
1038
1040
1039
1041
Attributes actualAttributes =
1040
1042
GENERATOR .generateMetricAttributeMapFromSpan (spanDataMock , resource ).get (DEPENDENCY_METRIC );
1041
- assertThat (actualAttributes .get (AWS_REMOTE_DB_USER )).isEqualTo (dbUser );
1043
+ assertThat (actualAttributes .get (AWS_REMOTE_OPERATION )).isEqualTo ("db_operation" );
1044
+ assertThat (actualAttributes .get (AWS_REMOTE_DB_USER )).isEqualTo ("db_user" );
1042
1045
}
1043
1046
1044
1047
@ Test
@@ -1053,18 +1056,20 @@ void testDBUserAttributeAbsent() {
1053
1056
1054
1057
@ Test
1055
1058
void testDBUserAttributeWithDifferentValues () {
1056
- String dbUser = "non_db_user" ;
1057
- mockAttribute (DB_USER , dbUser );
1059
+ mockAttribute (DB_SYSTEM , "db_system" );
1060
+ mockAttribute (DB_OPERATION , "db_operation" );
1061
+ mockAttribute (DB_STATEMENT , "db_statement" );
1062
+ mockAttribute (DB_USER , "non_db_user" );
1058
1063
when (spanDataMock .getKind ()).thenReturn (SpanKind .CLIENT );
1059
1064
1060
1065
Attributes actualAttributes =
1061
1066
GENERATOR .generateMetricAttributeMapFromSpan (spanDataMock , resource ).get (DEPENDENCY_METRIC );
1062
- assertThat (actualAttributes .get (AWS_REMOTE_DB_USER )).isEqualTo (dbUser );
1067
+ assertThat (actualAttributes .get (AWS_REMOTE_DB_USER )).isEqualTo ("non_db_user" );
1063
1068
}
1064
1069
1065
1070
@ Test
1066
1071
void testDBUserAttributeNotPresentInServiceMetricForServerSpan () {
1067
- String dbUser = "test_user " ;
1072
+ String dbUser = "db_user " ;
1068
1073
mockAttribute (DB_USER , dbUser );
1069
1074
when (spanDataMock .getKind ()).thenReturn (SpanKind .SERVER );
1070
1075
@@ -1073,6 +1078,24 @@ void testDBUserAttributeNotPresentInServiceMetricForServerSpan() {
1073
1078
assertThat (actualAttributes .get (AWS_REMOTE_DB_USER )).isNull ();
1074
1079
}
1075
1080
1081
+ @ Test
1082
+ public void testIsDbSpanTrue () {
1083
+ mockAttribute (DB_SYSTEM , "DB system" );
1084
+ mockAttribute (DB_OPERATION , "DB operation" );
1085
+ mockAttribute (DB_USER , "DB user" );
1086
+ when (spanDataMock .getKind ()).thenReturn (SpanKind .CLIENT );
1087
+
1088
+ assertThat (AwsSpanProcessingUtil .isDBSpan (spanDataMock )).isTrue ();
1089
+ }
1090
+
1091
+ @ Test
1092
+ public void testIsDbSpanFalse () {
1093
+ mockAttribute (DB_SYSTEM , null );
1094
+ when (spanDataMock .getKind ()).thenReturn (SpanKind .CLIENT );
1095
+
1096
+ assertThat (AwsSpanProcessingUtil .isDBSpan (spanDataMock )).isFalse ();
1097
+ }
1098
+
1076
1099
@ Test
1077
1100
public void testNormalizeRemoteServiceName_NoNormalization () {
1078
1101
String serviceName = "non aws service" ;
0 commit comments