1616
1717package com .splunk .opentelemetry ;
1818
19- import static io .opentelemetry .common .AttributeValue .longAttributeValue ;
20- import static io .opentelemetry .common .AttributeValue .stringAttributeValue ;
19+ import static io .opentelemetry .trace .attributes .SemanticAttributes .DB_SYSTEM ;
2120import static org .junit .jupiter .api .Assertions .assertTrue ;
2221import static org .junit .jupiter .params .provider .Arguments .arguments ;
2322import static org .mockito .Answers .RETURNS_DEEP_STUBS ;
@@ -53,19 +52,7 @@ void shouldRequireOnStart() {
5352 @ Test
5453 void shouldIgnoreSpansThatDoNotHaveDbSystemAttribute () {
5554 // given
56- given (span .toSpanData ().getAttributes ().get ("db.system" )).willReturn (null );
57-
58- // when
59- processor .onStart (span );
60-
61- // then
62- then (span ).should (never ()).updateName (anyString ());
63- }
64-
65- @ Test
66- void shouldIgnoreSpansThatHaveWrongTypeAttribute () {
67- // given
68- given (span .toSpanData ().getAttributes ().get ("db.system" )).willReturn (longAttributeValue (42 ));
55+ given (span .toSpanData ().getAttributes ().get (DB_SYSTEM )).willReturn (null );
6956
7057 // when
7158 processor .onStart (span );
@@ -77,8 +64,7 @@ void shouldIgnoreSpansThatHaveWrongTypeAttribute() {
7764 @ Test
7865 void shouldIgnoreSpansThatAreNotSql () {
7966 // given
80- given (span .toSpanData ().getAttributes ().get ("db.system" ))
81- .willReturn (stringAttributeValue ("mongodb" ));
67+ given (span .toSpanData ().getAttributes ().get (DB_SYSTEM )).willReturn ("mongodb" );
8268
8369 // when
8470 processor .onStart (span );
@@ -103,8 +89,7 @@ void shouldIgnoreSpansThatAreNotSql() {
10389 })
10490 void shouldUpdateJdbcSpans (String dbSystem ) {
10591 // given
106- given (span .toSpanData ().getAttributes ().get ("db.system" ))
107- .willReturn (stringAttributeValue (dbSystem ));
92+ given (span .toSpanData ().getAttributes ().get (DB_SYSTEM )).willReturn (dbSystem );
10893 given (span .getName ()).willReturn ("select * from table" );
10994
11095 // when
@@ -118,8 +103,7 @@ void shouldUpdateJdbcSpans(String dbSystem) {
118103 @ MethodSource ("spanNameArgs" )
119104 void shouldGetSqlStatementTypeFromSpanName (String query , String sqlStatementType ) {
120105 // given
121- given (span .toSpanData ().getAttributes ().get ("db.system" ))
122- .willReturn (stringAttributeValue ("other_sql" ));
106+ given (span .toSpanData ().getAttributes ().get (DB_SYSTEM )).willReturn ("other_sql" );
123107 given (span .getName ()).willReturn (query );
124108
125109 // when
0 commit comments