@@ -32,7 +32,7 @@ import {
3232 S3Client ,
3333} from '@aws-sdk/client-s3' ;
3434import { SQS } from '@aws-sdk/client-sqs' ;
35- import { SpanKind } from '@opentelemetry/api' ;
35+ import { propagation , SpanKind } from '@opentelemetry/api' ;
3636
3737// set aws environment variables, so tests in non aws environment are able to run
3838process . env . AWS_ACCESS_KEY_ID = 'testing' ;
@@ -45,15 +45,14 @@ import {
4545 ATTR_URL_FULL ,
4646 MESSAGINGOPERATIONVALUES_RECEIVE ,
4747 SEMATTRS_HTTP_STATUS_CODE ,
48- SEMATTRS_MESSAGING_DESTINATION ,
4948 SEMATTRS_MESSAGING_OPERATION ,
5049 SEMATTRS_MESSAGING_SYSTEM ,
51- SEMATTRS_MESSAGING_URL ,
5250 SEMATTRS_RPC_METHOD ,
5351 SEMATTRS_RPC_SERVICE ,
5452 SEMATTRS_RPC_SYSTEM ,
5553} from '@opentelemetry/semantic-conventions' ;
5654import {
55+ ATTR_MESSAGING_BATCH_MESSAGE_COUNT ,
5756 ATTR_MESSAGING_DESTINATION_NAME ,
5857 ATTR_MESSAGING_MESSAGE_ID ,
5958} from '../src/semconv' ;
@@ -421,6 +420,29 @@ describe('instrumentation-aws-sdk-v3', () => {
421420 expect ( span . attributes [ SEMATTRS_RPC_SERVICE ] ) . toEqual ( 'SQS' ) ;
422421 expect ( span . attributes [ AttributeNames . AWS_REGION ] ) . toEqual ( region ) ;
423422 expect ( span . attributes [ SEMATTRS_HTTP_STATUS_CODE ] ) . toEqual ( 200 ) ;
423+ expect ( span . attributes [ ATTR_MESSAGING_BATCH_MESSAGE_COUNT ] ) . toEqual (
424+ 2
425+ ) ;
426+ expect ( span . links . length ) . toBe ( 2 ) ;
427+
428+ const messages = res . Messages || [ ] ;
429+ expect ( messages . length ) . toEqual ( span . links . length ) ;
430+
431+ for ( let i = 0 ; i < span . links . length ; i ++ ) {
432+ const link = span . links [ i ] ;
433+ const messageId = messages [ i ] . MessageId ;
434+ const traceparent =
435+ messages [ i ] . MessageAttributes ?. traceparent . StringValue ?. split (
436+ '-'
437+ ) || [ ] ;
438+ const traceId = traceparent [ 1 ] ;
439+ const spanId = traceparent [ 2 ] ;
440+ expect ( link . attributes ?. [ ATTR_MESSAGING_MESSAGE_ID ] ) . toEqual (
441+ messageId
442+ ) ;
443+ expect ( link . context . traceId ) . toEqual ( traceId ) ;
444+ expect ( link . context . spanId ) . toEqual ( spanId ) ;
445+ }
424446 done ( ) ;
425447 } ) ;
426448 } ) ;
0 commit comments