@@ -374,23 +374,25 @@ public void testServerSpanWithNullSpanName() {
374374 public void testServerSpanWithSpanNameAsHttpMethod () {
375375 updateResourceWithServiceName ();
376376 when (spanDataMock .getName ()).thenReturn ("GET" );
377- mockAttribute (HTTP_METHOD , "GET" );
378-
379377 Attributes expectedAttributes =
380378 Attributes .of (
381379 AWS_SPAN_KIND , SpanKind .SERVER .name (),
382380 AWS_LOCAL_SERVICE , SERVICE_NAME_VALUE ,
383381 AWS_LOCAL_OPERATION , UNKNOWN_OPERATION );
382+ // Validate the span with http.method.
383+ mockAttribute (HTTP_METHOD , "GET" );
384384 validateAttributesProducedForNonLocalRootSpanOfKind (expectedAttributes , SpanKind .SERVER );
385385 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 );
386390 }
387391
388392 @ Test
389393 public void testServerSpanWithSpanNameWithHttpTarget () {
390394 updateResourceWithServiceName ();
391395 when (spanDataMock .getName ()).thenReturn ("POST" );
392- mockAttribute (HTTP_METHOD , "POST" );
393- mockAttribute (HTTP_TARGET , "/payment/123" );
394396
395397 Attributes expectedAttributes =
396398 Attributes .of (
@@ -400,9 +402,18 @@ public void testServerSpanWithSpanNameWithHttpTarget() {
400402 SERVICE_NAME_VALUE ,
401403 AWS_LOCAL_OPERATION ,
402404 "POST /payment" );
405+ // Validate the span with http.method and http.target.
406+ mockAttribute (HTTP_METHOD , "POST" );
407+ mockAttribute (HTTP_TARGET , "/payment/123" );
403408 validateAttributesProducedForNonLocalRootSpanOfKind (expectedAttributes , SpanKind .SERVER );
404409 mockAttribute (HTTP_METHOD , null );
405410 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 );
406417 }
407418
408419 @ Test
@@ -507,18 +518,35 @@ public void testRemoteAttributesCombinations() {
507518 validateExpectedRemoteAttributes ("www.example.com" , UNKNOWN_REMOTE_OPERATION );
508519 mockAttribute (NET_PEER_NAME , null );
509520
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+
510526 // Validate behaviour of extracting Remote Service from net.peer.name and net.peer.port
511527 mockAttribute (NET_PEER_NAME , "192.168.0.0" );
512528 mockAttribute (NET_PEER_PORT , 8081L );
513529 validateExpectedRemoteAttributes ("192.168.0.0:8081" , UNKNOWN_REMOTE_OPERATION );
514530 mockAttribute (NET_PEER_NAME , null );
515531 mockAttribute (NET_PEER_PORT , null );
516532
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+
517540 // Validate behaviour of extracting Remote Service from net.peer.socket.addr
518541 mockAttribute (NET_SOCK_PEER_ADDR , "www.example.com" );
519542 validateExpectedRemoteAttributes ("www.example.com" , UNKNOWN_REMOTE_OPERATION );
520543 mockAttribute (NET_SOCK_PEER_ADDR , null );
521544
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+
522550 // Validate behaviour of extracting Remote Service from net.peer.socket.addr and
523551 // net.sock.peer.port
524552 mockAttribute (NET_SOCK_PEER_ADDR , "192.168.0.0" );
@@ -527,43 +555,86 @@ public void testRemoteAttributesCombinations() {
527555 mockAttribute (NET_SOCK_PEER_ADDR , null );
528556 mockAttribute (NET_SOCK_PEER_PORT , null );
529557
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+
530566 // Validate behavior of Remote Operation from HttpTarget - with 1st api part. Also validates
531567 // that RemoteService is extracted from HttpUrl.
532568 mockAttribute (HTTP_URL , "http://www.example.com/payment/123" );
533569 validateExpectedRemoteAttributes ("www.example.com" , "/payment" );
534570 mockAttribute (HTTP_URL , null );
535571
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+
536577 // Validate behavior of Remote Operation from HttpTarget - with 1st api part. Also validates
537578 // that RemoteService is extracted from HttpUrl.
538579 mockAttribute (HTTP_URL , "http://www.example.com" );
539580 validateExpectedRemoteAttributes ("www.example.com" , "/" );
540581 mockAttribute (HTTP_URL , null );
541582
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+
542588 // Validate behavior of Remote Service from HttpUrl
543589 mockAttribute (HTTP_URL , "http://192.168.1.1:8000" );
544590 validateExpectedRemoteAttributes ("192.168.1.1:8000" , "/" );
545591 mockAttribute (HTTP_URL , null );
546592
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+
547598 // Validate behavior of Remote Service from HttpUrl
548599 mockAttribute (HTTP_URL , "http://192.168.1.1" );
549600 validateExpectedRemoteAttributes ("192.168.1.1" , "/" );
550601 mockAttribute (HTTP_URL , null );
551602
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+
552608 // Validate behavior of Remote Service from HttpUrl
553609 mockAttribute (HTTP_URL , "" );
554610 validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
555611 mockAttribute (HTTP_URL , null );
556612
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+
557618 // Validate behavior of Remote Service from HttpUrl
558619 mockAttribute (HTTP_URL , null );
559620 validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
560621 mockAttribute (HTTP_URL , null );
561622
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+
562628 // Validate behavior of Remote Operation from HttpTarget - invalid url, then remove it
563629 mockAttribute (HTTP_URL , "abc" );
564630 validateExpectedRemoteAttributes (UNKNOWN_REMOTE_SERVICE , UNKNOWN_REMOTE_OPERATION );
565631 mockAttribute (HTTP_URL , null );
566632
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+
567638 // Validate behaviour of Peer service attribute, then remove it.
568639 mockAttribute (PEER_SERVICE , "Peer service" );
569640 validateExpectedRemoteAttributes ("Peer service" , UNKNOWN_REMOTE_OPERATION );
@@ -660,7 +731,9 @@ public void testPeerServiceDoesOverrideOtherRemoteServices() {
660731 validatePeerServiceDoesOverride (MESSAGING_SYSTEM );
661732 validatePeerServiceDoesOverride (GRAPHQL_OPERATION_TYPE );
662733 validatePeerServiceDoesOverride (NET_PEER_NAME );
734+ validatePeerServiceDoesOverride (SERVER_ADDRESS );
663735 validatePeerServiceDoesOverride (NET_SOCK_PEER_ADDR );
736+ validatePeerServiceDoesOverride (NETWORK_PEER_ADDRESS );
664737 // Actually testing that peer service overrides "UnknownRemoteService".
665738 validatePeerServiceDoesOverride (AttributeKey .stringKey ("unknown.service.key" ));
666739 }
0 commit comments