@@ -374,23 +374,25 @@ public void testServerSpanWithNullSpanName() {
374
374
public void testServerSpanWithSpanNameAsHttpMethod () {
375
375
updateResourceWithServiceName ();
376
376
when (spanDataMock .getName ()).thenReturn ("GET" );
377
- mockAttribute (HTTP_METHOD , "GET" );
378
-
379
377
Attributes expectedAttributes =
380
378
Attributes .of (
381
379
AWS_SPAN_KIND , SpanKind .SERVER .name (),
382
380
AWS_LOCAL_SERVICE , SERVICE_NAME_VALUE ,
383
381
AWS_LOCAL_OPERATION , UNKNOWN_OPERATION );
382
+ // Validate the span with http.method.
383
+ mockAttribute (HTTP_METHOD , "GET" );
384
384
validateAttributesProducedForNonLocalRootSpanOfKind (expectedAttributes , SpanKind .SERVER );
385
385
mockAttribute (HTTP_METHOD , null );
386
+ // Validate the span with http.request.method.
387
+ mockAttribute (HTTP_REQUEST_METHOD , "GET" );
388
+ validateAttributesProducedForNonLocalRootSpanOfKind (expectedAttributes , SpanKind .SERVER );
389
+ mockAttribute (HTTP_REQUEST_METHOD , null );
386
390
}
387
391
388
392
@ Test
389
393
public void testServerSpanWithSpanNameWithHttpTarget () {
390
394
updateResourceWithServiceName ();
391
395
when (spanDataMock .getName ()).thenReturn ("POST" );
392
- mockAttribute (HTTP_METHOD , "POST" );
393
- mockAttribute (HTTP_TARGET , "/payment/123" );
394
396
395
397
Attributes expectedAttributes =
396
398
Attributes .of (
@@ -400,9 +402,18 @@ public void testServerSpanWithSpanNameWithHttpTarget() {
400
402
SERVICE_NAME_VALUE ,
401
403
AWS_LOCAL_OPERATION ,
402
404
"POST /payment" );
405
+ // Validate the span with http.method and http.target.
406
+ mockAttribute (HTTP_METHOD , "POST" );
407
+ mockAttribute (HTTP_TARGET , "/payment/123" );
403
408
validateAttributesProducedForNonLocalRootSpanOfKind (expectedAttributes , SpanKind .SERVER );
404
409
mockAttribute (HTTP_METHOD , null );
405
410
mockAttribute (HTTP_TARGET , null );
411
+ // Validate the span with http.request.method and url.path.
412
+ mockAttribute (HTTP_REQUEST_METHOD , "POST" );
413
+ mockAttribute (URL_PATH , "/payment/123" );
414
+ validateAttributesProducedForNonLocalRootSpanOfKind (expectedAttributes , SpanKind .SERVER );
415
+ mockAttribute (HTTP_REQUEST_METHOD , null );
416
+ mockAttribute (URL_PATH , null );
406
417
}
407
418
408
419
@ Test
@@ -507,18 +518,35 @@ public void testRemoteAttributesCombinations() {
507
518
validateExpectedRemoteAttributes ("www.example.com" , UNKNOWN_REMOTE_OPERATION );
508
519
mockAttribute (NET_PEER_NAME , null );
509
520
521
+ // Validate behaviour of extracting Remote Service from service.address
522
+ mockAttribute (SERVER_ADDRESS , "www.example.com" );
523
+ validateExpectedRemoteAttributes ("www.example.com" , UNKNOWN_REMOTE_OPERATION );
524
+ mockAttribute (SERVER_ADDRESS , null );
525
+
510
526
// Validate behaviour of extracting Remote Service from net.peer.name and net.peer.port
511
527
mockAttribute (NET_PEER_NAME , "192.168.0.0" );
512
528
mockAttribute (NET_PEER_PORT , 8081L );
513
529
validateExpectedRemoteAttributes ("192.168.0.0:8081" , UNKNOWN_REMOTE_OPERATION );
514
530
mockAttribute (NET_PEER_NAME , null );
515
531
mockAttribute (NET_PEER_PORT , null );
516
532
533
+ // Validate behaviour of extracting Remote Service from service.address and service.port
534
+ mockAttribute (SERVER_ADDRESS , "192.168.0.0" );
535
+ mockAttribute (SERVER_PORT , 8081L );
536
+ validateExpectedRemoteAttributes ("192.168.0.0:8081" , UNKNOWN_REMOTE_OPERATION );
537
+ mockAttribute (SERVER_ADDRESS , null );
538
+ mockAttribute (SERVER_PORT , null );
539
+
517
540
// Validate behaviour of extracting Remote Service from net.peer.socket.addr
518
541
mockAttribute (NET_SOCK_PEER_ADDR , "www.example.com" );
519
542
validateExpectedRemoteAttributes ("www.example.com" , UNKNOWN_REMOTE_OPERATION );
520
543
mockAttribute (NET_SOCK_PEER_ADDR , null );
521
544
545
+ // Validate behaviour of extracting Remote Service from net.peer.socket.addr
546
+ mockAttribute (NETWORK_PEER_ADDRESS , "www.example.com" );
547
+ validateExpectedRemoteAttributes ("www.example.com" , UNKNOWN_REMOTE_OPERATION );
548
+ mockAttribute (NETWORK_PEER_ADDRESS , null );
549
+
522
550
// Validate behaviour of extracting Remote Service from net.peer.socket.addr and
523
551
// net.sock.peer.port
524
552
mockAttribute (NET_SOCK_PEER_ADDR , "192.168.0.0" );
@@ -527,43 +555,86 @@ public void testRemoteAttributesCombinations() {
527
555
mockAttribute (NET_SOCK_PEER_ADDR , null );
528
556
mockAttribute (NET_SOCK_PEER_PORT , null );
529
557
558
+ // Validate behaviour of extracting Remote Service from net.peer.socket.addr and
559
+ // net.sock.peer.port
560
+ mockAttribute (NETWORK_PEER_ADDRESS , "192.168.0.0" );
561
+ mockAttribute (NETWORK_PEER_PORT , 8081L );
562
+ validateExpectedRemoteAttributes ("192.168.0.0:8081" , UNKNOWN_REMOTE_OPERATION );
563
+ mockAttribute (NETWORK_PEER_ADDRESS , null );
564
+ mockAttribute (NETWORK_PEER_PORT , null );
565
+
530
566
// Validate behavior of Remote Operation from HttpTarget - with 1st api part. Also validates
531
567
// that RemoteService is extracted from HttpUrl.
532
568
mockAttribute (HTTP_URL , "http://www.example.com/payment/123" );
533
569
validateExpectedRemoteAttributes ("www.example.com" , "/payment" );
534
570
mockAttribute (HTTP_URL , null );
535
571
572
+ // that RemoteService is extracted from url.full.
573
+ mockAttribute (URL_FULL , "http://www.example.com/payment/123" );
574
+ validateExpectedRemoteAttributes ("www.example.com" , "/payment" );
575
+ mockAttribute (URL_FULL , null );
576
+
536
577
// Validate behavior of Remote Operation from HttpTarget - with 1st api part. Also validates
537
578
// that RemoteService is extracted from HttpUrl.
538
579
mockAttribute (HTTP_URL , "http://www.example.com" );
539
580
validateExpectedRemoteAttributes ("www.example.com" , "/" );
540
581
mockAttribute (HTTP_URL , null );
541
582
583
+ // that RemoteService is extracted from url.full.
584
+ mockAttribute (URL_FULL , "http://www.example.com" );
585
+ validateExpectedRemoteAttributes ("www.example.com" , "/" );
586
+ mockAttribute (URL_FULL , null );
587
+
542
588
// Validate behavior of Remote Service from HttpUrl
543
589
mockAttribute (HTTP_URL , "http://192.168.1.1:8000" );
544
590
validateExpectedRemoteAttributes ("192.168.1.1:8000" , "/" );
545
591
mockAttribute (HTTP_URL , null );
546
592
593
+ // Validate behavior of Remote Service from url.full
594
+ mockAttribute (URL_FULL , "http://192.168.1.1:8000" );
595
+ validateExpectedRemoteAttributes ("192.168.1.1:8000" , "/" );
596
+ mockAttribute (URL_FULL , null );
597
+
547
598
// Validate behavior of Remote Service from HttpUrl
548
599
mockAttribute (HTTP_URL , "http://192.168.1.1" );
549
600
validateExpectedRemoteAttributes ("192.168.1.1" , "/" );
550
601
mockAttribute (HTTP_URL , null );
551
602
603
+ // Validate behavior of Remote Service from url.full
604
+ mockAttribute (URL_FULL , "http://192.168.1.1" );
605
+ validateExpectedRemoteAttributes ("192.168.1.1" , "/" );
606
+ mockAttribute (URL_FULL , null );
607
+
552
608
// Validate behavior of Remote Service from HttpUrl
553
609
mockAttribute (HTTP_URL , "" );
554
610
validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
555
611
mockAttribute (HTTP_URL , null );
556
612
613
+ // Validate behavior of Remote Service from url.full
614
+ mockAttribute (URL_FULL , "" );
615
+ validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
616
+ mockAttribute (URL_FULL , null );
617
+
557
618
// Validate behavior of Remote Service from HttpUrl
558
619
mockAttribute (HTTP_URL , null );
559
620
validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
560
621
mockAttribute (HTTP_URL , null );
561
622
623
+ // Validate behavior of Remote Service from url.full
624
+ mockAttribute (URL_FULL , null );
625
+ validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
626
+ mockAttribute (URL_FULL , null );
627
+
562
628
// Validate behavior of Remote Operation from HttpTarget - invalid url, then remove it
563
629
mockAttribute (HTTP_URL , "abc" );
564
630
validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
565
631
mockAttribute (HTTP_URL , null );
566
632
633
+ // Validate behavior of Remote Operation from url.full - invalid url, then remove it
634
+ mockAttribute (URL_FULL , "abc" );
635
+ validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
636
+ mockAttribute (URL_FULL , null );
637
+
567
638
// Validate behaviour of Peer service attribute, then remove it.
568
639
mockAttribute (PEER_SERVICE , "Peer service" );
569
640
validateExpectedRemoteAttributes ("Peer service" , UNKNOWN_REMOTE_OPERATION );
@@ -660,7 +731,9 @@ public void testPeerServiceDoesOverrideOtherRemoteServices() {
660
731
validatePeerServiceDoesOverride (MESSAGING_SYSTEM );
661
732
validatePeerServiceDoesOverride (GRAPHQL_OPERATION_TYPE );
662
733
validatePeerServiceDoesOverride (NET_PEER_NAME );
734
+ validatePeerServiceDoesOverride (SERVER_ADDRESS );
663
735
validatePeerServiceDoesOverride (NET_SOCK_PEER_ADDR );
736
+ validatePeerServiceDoesOverride (NETWORK_PEER_ADDRESS );
664
737
// Actually testing that peer service overrides "UnknownRemoteService".
665
738
validatePeerServiceDoesOverride (AttributeKey .stringKey ("unknown.service.key" ));
666
739
}
0 commit comments