55
66package io .opentelemetry .javaagent .instrumentation .spring .webflux .v5_0 .server ;
77
8- import static io .opentelemetry .api .common .AttributeKey .stringKey ;
98import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .assertThat ;
109import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
1110import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .satisfies ;
2524import static io .opentelemetry .semconv .UrlAttributes .URL_PATH ;
2625import static io .opentelemetry .semconv .UrlAttributes .URL_SCHEME ;
2726import static io .opentelemetry .semconv .UserAgentAttributes .USER_AGENT_ORIGINAL ;
27+ import static io .opentelemetry .semconv .incubating .CodeIncubatingAttributes .CODE_FUNCTION ;
28+ import static io .opentelemetry .semconv .incubating .CodeIncubatingAttributes .CODE_NAMESPACE ;
2829import static org .junit .jupiter .api .Named .named ;
2930
3031import io .opentelemetry .api .trace .SpanKind ;
@@ -139,7 +140,12 @@ void basicGetTest(Parameter parameter) {
139140 .hasParent (trace .getSpan (0 ))
140141 .hasAttributesSatisfyingExactly (
141142 satisfies (
142- stringKey ("spring-webflux.handler.type" ),
143+ CODE_FUNCTION ,
144+ parameter .annotatedMethod == null
145+ ? val -> val .isEqualTo ("handle" )
146+ : val -> val .isEqualTo (parameter .annotatedMethod )),
147+ satisfies (
148+ CODE_NAMESPACE ,
143149 parameter .annotatedMethod == null
144150 ? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
145151 : val -> val .isEqualTo (TestController .class .getName ())));
@@ -258,7 +264,12 @@ void getAsyncResponseTest(Parameter parameter) {
258264 .hasParent (trace .getSpan (0 ))
259265 .hasAttributesSatisfyingExactly (
260266 satisfies (
261- stringKey ("spring-webflux.handler.type" ),
267+ CODE_FUNCTION ,
268+ parameter .annotatedMethod == null
269+ ? val -> val .isEqualTo ("handle" )
270+ : val -> val .isEqualTo (parameter .annotatedMethod )),
271+ satisfies (
272+ CODE_NAMESPACE ,
262273 parameter .annotatedMethod == null
263274 ? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
264275 : val -> val .isEqualTo (TestController .class .getName ())));
@@ -364,7 +375,12 @@ void createSpanDuringHandlerFunctionTest(Parameter parameter) {
364375 .hasParent (trace .getSpan (0 ))
365376 .hasAttributesSatisfyingExactly (
366377 satisfies (
367- stringKey ("spring-webflux.handler.type" ),
378+ CODE_FUNCTION ,
379+ parameter .annotatedMethod == null
380+ ? val -> val .isEqualTo ("handle" )
381+ : val -> val .isEqualTo (parameter .annotatedMethod )),
382+ satisfies (
383+ CODE_NAMESPACE ,
368384 parameter .annotatedMethod == null
369385 ? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
370386 : val -> val .isEqualTo (TestController .class .getName ())));
@@ -428,8 +444,9 @@ void get404Test() {
428444 .hasStatus (StatusData .error ())
429445 .hasEventsSatisfyingExactly (SpringWebfluxTest ::resource404Exception )
430446 .hasAttributesSatisfyingExactly (
447+ equalTo (CODE_FUNCTION , "handle" ),
431448 equalTo (
432- stringKey ( "spring-webflux.handler.type" ) ,
449+ CODE_NAMESPACE ,
433450 "org.springframework.web.reactive.resource.ResourceWebHandler" ))));
434451 }
435452
@@ -485,9 +502,8 @@ void basicPostTest() {
485502 .hasKind (SpanKind .INTERNAL )
486503 .hasParent (trace .getSpan (0 ))
487504 .hasAttributesSatisfyingExactly (
488- satisfies (
489- stringKey ("spring-webflux.handler.type" ),
490- val -> val .contains (EchoHandlerFunction .class .getName ()))),
505+ equalTo (CODE_FUNCTION , "handle" ),
506+ equalTo (CODE_NAMESPACE , EchoHandlerFunction .class .getName ())),
491507 span ->
492508 span .hasName ("echo" ).hasParent (trace .getSpan (1 )).hasTotalAttributeCount (0 )));
493509 }
@@ -545,7 +561,12 @@ void getToBadEndpointTest(Parameter parameter) {
545561 val -> val .isInstanceOf (String .class ))))
546562 .hasAttributesSatisfyingExactly (
547563 satisfies (
548- stringKey ("spring-webflux.handler.type" ),
564+ CODE_FUNCTION ,
565+ parameter .annotatedMethod == null
566+ ? val -> val .isEqualTo ("handle" )
567+ : val -> val .isEqualTo (parameter .annotatedMethod )),
568+ satisfies (
569+ CODE_NAMESPACE ,
549570 parameter .annotatedMethod == null
550571 ? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
551572 : val -> val .isEqualTo (TestController .class .getName ())));
@@ -603,8 +624,9 @@ void redirectTest() {
603624 .hasKind (SpanKind .INTERNAL )
604625 .hasParent (trace .getSpan (0 ))
605626 .hasAttributesSatisfyingExactly (
627+ equalTo (CODE_FUNCTION , "handle" ),
606628 satisfies (
607- stringKey ( "spring-webflux.handler.type" ) ,
629+ CODE_NAMESPACE ,
608630 val -> val .startsWith ("server.RedirectComponent$$Lambda" )))),
609631 trace ->
610632 trace .hasSpansSatisfyingExactly (
@@ -631,8 +653,9 @@ void redirectTest() {
631653 span .hasKind (SpanKind .INTERNAL )
632654 .hasParent (trace .getSpan (0 ))
633655 .hasAttributesSatisfyingExactly (
656+ equalTo (CODE_FUNCTION , "handle" ),
634657 satisfies (
635- stringKey ( "spring-webflux.handler.type" ) ,
658+ CODE_NAMESPACE ,
636659 val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )));
637660 }));
638661 }
@@ -689,7 +712,12 @@ void multipleGetsToDelayingRoute(Parameter parameter) {
689712 .hasParent (trace .getSpan (0 ))
690713 .hasAttributesSatisfyingExactly (
691714 satisfies (
692- stringKey ("spring-webflux.handler.type" ),
715+ CODE_FUNCTION ,
716+ parameter .annotatedMethod == null
717+ ? val -> val .isEqualTo ("handle" )
718+ : val -> val .isEqualTo (parameter .annotatedMethod )),
719+ satisfies (
720+ CODE_NAMESPACE ,
693721 parameter .annotatedMethod == null
694722 ? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
695723 : val -> val .isEqualTo (TestController .class .getName ())));
@@ -760,10 +788,11 @@ void cancelRequestTest() throws Exception {
760788 .hasKind (SpanKind .INTERNAL )
761789 .hasParent (trace .getSpan (0 ))
762790 .hasAttributesSatisfyingExactly (
791+ equalTo (CODE_FUNCTION , "handle" ),
763792 satisfies (
764- stringKey ( "spring-webflux.handler.type" ) ,
765- value ->
766- value .startsWith (
793+ CODE_NAMESPACE ,
794+ val ->
795+ val .startsWith (
767796 "server.SpringWebFluxTestApplication$$Lambda" )))));
768797
769798 SpringWebFluxTestApplication .resumeSlowRequest ();
0 commit comments