@@ -443,6 +443,11 @@ static Stream<Arguments> cases() {
443443 Arguments .of (
444444 "minimal span — default UNSPECIFIED kind" ,
445445 asList (span ("GET /api/users" , "servlet.request" , "web" ))),
446+
447+ // ── null span type — regression: must not NPE, span.type attribute omitted ─
448+ Arguments .of (
449+ "null span type — span.type attribute omitted, no NPE" ,
450+ asList (span ("GET /api/users" , "servlet.request" , null ))),
446451 Arguments .of ("internal span kind" , asList (kindSpan ("GET /api/users" , SPAN_KIND_INTERNAL ))),
447452 Arguments .of ("server span kind" , asList (kindSpan ("GET /api/users" , SPAN_KIND_SERVER ))),
448453 Arguments .of ("client span kind" , asList (kindSpan ("redis.get" , SPAN_KIND_CLIENT ))),
@@ -1029,8 +1034,14 @@ private static void verifySpan(CodedInputStream sp, DDSpan span, SpanSpec spec,
10291034 assertTrue (
10301035 attrKeys .contains ("operation.name" ),
10311036 "attributes must include 'operation.name' [" + caseName + "]" );
1032- assertTrue (
1033- attrKeys .contains ("span.type" ), "attributes must include 'span.type' [" + caseName + "]" );
1037+ if (spec .spanType != null ) {
1038+ assertTrue (
1039+ attrKeys .contains ("span.type" ), "attributes must include 'span.type' [" + caseName + "]" );
1040+ } else {
1041+ assertFalse (
1042+ attrKeys .contains ("span.type" ),
1043+ "attributes must omit 'span.type' when null [" + caseName + "]" );
1044+ }
10341045
10351046 // service.name attribute is written only when the span's service differs from the default
10361047 if (spec .serviceName != null ) {
0 commit comments