@@ -24,7 +24,7 @@ import * as sinon from 'sinon';
2424import { AWSXRAY_TRACE_ID_HEADER , AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray' ;
2525import { Context } from 'aws-lambda' ;
2626import { SinonStub } from 'sinon' ;
27- import { S3 } from '@aws-sdk/client-s3 ' ;
27+ import { Lambda } from '@aws-sdk/client-lambda ' ;
2828import nock = require( 'nock' ) ;
2929import { ReadableSpan } from '@opentelemetry/sdk-trace-base' ;
3030import { getTestSpans } from '@opentelemetry/contrib-test-utils' ;
@@ -532,7 +532,7 @@ describe('InstrumentationPatchTest', () => {
532532 }
533533
534534 describe ( 'AwsSdkInstrumentationPatchTest' , ( ) => {
535- let s3 : S3 ;
535+ let lambda : Lambda ;
536536 const region = 'us-east-1' ;
537537
538538 it ( 'overridden _getV3SmithyClientSendPatch updates MiddlewareStack' , async ( ) => {
@@ -566,41 +566,41 @@ describe('InstrumentationPatchTest', () => {
566566 } ) ;
567567
568568 it ( 'injects trace context header into request via propagator' , async ( ) => {
569- s3 = new S3 ( {
569+ lambda = new Lambda ( {
570570 region : region ,
571571 credentials : {
572572 accessKeyId : 'abcde' ,
573573 secretAccessKey : 'abcde' ,
574574 } ,
575575 } ) ;
576576
577- const dummyBucketName : string = 'dummy-bucket -name' ;
577+ const dummyFunctionName : string = 'dummy-function -name' ;
578578 let reqHeaders : any = { } ;
579579
580- nock ( `https://${ dummyBucketName } .s3 .${ region } .amazonaws.com` )
581- . get ( '/' )
580+ nock ( `https://lambda .${ region } .amazonaws.com` )
581+ . post ( `/2015-03-31/functions/ ${ dummyFunctionName } /invocations` )
582582 . reply ( 200 , function ( uri : any , requestBody : any ) {
583583 reqHeaders = this . req . headers ;
584584 return 'null' ;
585585 } ) ;
586586
587- await s3
588- . listObjects ( {
589- Bucket : dummyBucketName ,
587+ await lambda
588+ . invoke ( {
589+ FunctionName : dummyFunctionName ,
590590 } )
591591 . catch ( ( err : any ) => { } ) ;
592592
593593 const testSpans : ReadableSpan [ ] = getTestSpans ( ) ;
594- const listObjectsSpans : ReadableSpan [ ] = testSpans . filter ( ( s : ReadableSpan ) => {
595- return s . name === 'S3.ListObjects ' ;
594+ const invokeSpans : ReadableSpan [ ] = testSpans . filter ( ( s : ReadableSpan ) => {
595+ return s . name === 'dummy-function-name Invoke ' ;
596596 } ) ;
597597
598- expect ( listObjectsSpans . length ) . toBe ( 1 ) ;
598+ expect ( invokeSpans . length ) . toBe ( 1 ) ;
599599
600- const traceId = listObjectsSpans [ 0 ] . spanContext ( ) . traceId ;
601- const spanId = listObjectsSpans [ 0 ] . spanContext ( ) . spanId ;
600+ const traceId = invokeSpans [ 0 ] . spanContext ( ) . traceId ;
601+ const spanId = invokeSpans [ 0 ] . spanContext ( ) . spanId ;
602602 expect ( reqHeaders [ 'x-amzn-trace-id' ] as string ) . toEqual (
603- `Root=1-${ traceId . substring ( 0 , 8 ) } -${ listObjectsSpans [ 0 ]
603+ `Root=1-${ traceId . substring ( 0 , 8 ) } -${ invokeSpans [ 0 ]
604604 . spanContext ( )
605605 . traceId . substring ( 8 , 32 ) } ;Parent=${ spanId } ;Sampled=1`
606606 ) ;
0 commit comments