5
5
6
6
package io .opentelemetry .javaagent .instrumentation .spring .webflux .v5_0 .server ;
7
7
8
- import static io .opentelemetry .api .common .AttributeKey .stringKey ;
9
8
import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .assertThat ;
10
9
import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .equalTo ;
11
10
import static io .opentelemetry .sdk .testing .assertj .OpenTelemetryAssertions .satisfies ;
25
24
import static io .opentelemetry .semconv .UrlAttributes .URL_PATH ;
26
25
import static io .opentelemetry .semconv .UrlAttributes .URL_SCHEME ;
27
26
import 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 ;
28
29
import static org .junit .jupiter .api .Named .named ;
29
30
30
31
import io .opentelemetry .api .trace .SpanKind ;
@@ -139,7 +140,12 @@ void basicGetTest(Parameter parameter) {
139
140
.hasParent (trace .getSpan (0 ))
140
141
.hasAttributesSatisfyingExactly (
141
142
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 ,
143
149
parameter .annotatedMethod == null
144
150
? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
145
151
: val -> val .isEqualTo (TestController .class .getName ())));
@@ -258,7 +264,12 @@ void getAsyncResponseTest(Parameter parameter) {
258
264
.hasParent (trace .getSpan (0 ))
259
265
.hasAttributesSatisfyingExactly (
260
266
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 ,
262
273
parameter .annotatedMethod == null
263
274
? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
264
275
: val -> val .isEqualTo (TestController .class .getName ())));
@@ -364,7 +375,12 @@ void createSpanDuringHandlerFunctionTest(Parameter parameter) {
364
375
.hasParent (trace .getSpan (0 ))
365
376
.hasAttributesSatisfyingExactly (
366
377
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 ,
368
384
parameter .annotatedMethod == null
369
385
? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
370
386
: val -> val .isEqualTo (TestController .class .getName ())));
@@ -428,8 +444,9 @@ void get404Test() {
428
444
.hasStatus (StatusData .error ())
429
445
.hasEventsSatisfyingExactly (SpringWebfluxTest ::resource404Exception )
430
446
.hasAttributesSatisfyingExactly (
447
+ equalTo (CODE_FUNCTION , "handle" ),
431
448
equalTo (
432
- stringKey ( "spring-webflux.handler.type" ) ,
449
+ CODE_NAMESPACE ,
433
450
"org.springframework.web.reactive.resource.ResourceWebHandler" ))));
434
451
}
435
452
@@ -485,9 +502,8 @@ void basicPostTest() {
485
502
.hasKind (SpanKind .INTERNAL )
486
503
.hasParent (trace .getSpan (0 ))
487
504
.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 ())),
491
507
span ->
492
508
span .hasName ("echo" ).hasParent (trace .getSpan (1 )).hasTotalAttributeCount (0 )));
493
509
}
@@ -545,7 +561,12 @@ void getToBadEndpointTest(Parameter parameter) {
545
561
val -> val .isInstanceOf (String .class ))))
546
562
.hasAttributesSatisfyingExactly (
547
563
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 ,
549
570
parameter .annotatedMethod == null
550
571
? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
551
572
: val -> val .isEqualTo (TestController .class .getName ())));
@@ -603,8 +624,9 @@ void redirectTest() {
603
624
.hasKind (SpanKind .INTERNAL )
604
625
.hasParent (trace .getSpan (0 ))
605
626
.hasAttributesSatisfyingExactly (
627
+ equalTo (CODE_FUNCTION , "handle" ),
606
628
satisfies (
607
- stringKey ( "spring-webflux.handler.type" ) ,
629
+ CODE_NAMESPACE ,
608
630
val -> val .startsWith ("server.RedirectComponent$$Lambda" )))),
609
631
trace ->
610
632
trace .hasSpansSatisfyingExactly (
@@ -631,8 +653,9 @@ void redirectTest() {
631
653
span .hasKind (SpanKind .INTERNAL )
632
654
.hasParent (trace .getSpan (0 ))
633
655
.hasAttributesSatisfyingExactly (
656
+ equalTo (CODE_FUNCTION , "handle" ),
634
657
satisfies (
635
- stringKey ( "spring-webflux.handler.type" ) ,
658
+ CODE_NAMESPACE ,
636
659
val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )));
637
660
}));
638
661
}
@@ -689,7 +712,12 @@ void multipleGetsToDelayingRoute(Parameter parameter) {
689
712
.hasParent (trace .getSpan (0 ))
690
713
.hasAttributesSatisfyingExactly (
691
714
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 ,
693
721
parameter .annotatedMethod == null
694
722
? val -> val .contains (INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX )
695
723
: val -> val .isEqualTo (TestController .class .getName ())));
@@ -760,10 +788,11 @@ void cancelRequestTest() throws Exception {
760
788
.hasKind (SpanKind .INTERNAL )
761
789
.hasParent (trace .getSpan (0 ))
762
790
.hasAttributesSatisfyingExactly (
791
+ equalTo (CODE_FUNCTION , "handle" ),
763
792
satisfies (
764
- stringKey ( "spring-webflux.handler.type" ) ,
765
- value ->
766
- value .startsWith (
793
+ CODE_NAMESPACE ,
794
+ val ->
795
+ val .startsWith (
767
796
"server.SpringWebFluxTestApplication$$Lambda" )))));
768
797
769
798
SpringWebFluxTestApplication .resumeSlowRequest ();
0 commit comments