Skip to content

Commit

Permalink
test(sendMessageBatch): add sqs test (open-telemetry#1063)
Browse files Browse the repository at this point in the history
* fix(sendMessageBatch): add sqs test

* fix(sendMessageBatch): remove unused parameter

* fix(fix comment): fix comment
  • Loading branch information
haddasbronfman authored Aug 9, 2022
1 parent d358c1c commit 8a90e78
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,60 @@ describe('instrumentation-aws-sdk-v3', () => {
);
});

it('sqs send message batch attributes', async () => {
nock(`https://sqs.${region}.amazonaws.com/`)
.post('/')
.reply(
200,
fs.readFileSync('./test/mock-responses/sqs-send-batch.xml', 'utf8')
);
const params = {
QueueUrl:
'https://sqs.us-east-1.amazonaws.com/731241200085/otel-demo-aws-sdk',
MessageBody: 'payload example from v3 without batch',
Entries: [
{
Id: '1000',
MessageBody: 'msg body for 1000',
},
{
Id: '1001',
MessageBody: 'msg body for 1001',
},
],
};
await sqsClient.sendMessageBatch(params);
expect(getTestSpans().length).toBe(1);
const [span] = getTestSpans();

// make sure we have the general aws attributes:
expect(span.attributes[SemanticAttributes.RPC_SYSTEM]).toEqual(
'aws-api'
);
expect(span.attributes[SemanticAttributes.RPC_METHOD]).toEqual(
'SendMessageBatch'
);
expect(span.attributes[SemanticAttributes.RPC_SERVICE]).toEqual('SQS');
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);

// messaging semantic attributes
expect(span.attributes[SemanticAttributes.MESSAGING_SYSTEM]).toEqual(
'aws.sqs'
);
expect(
span.attributes[SemanticAttributes.MESSAGING_DESTINATION_KIND]
).toEqual(MessagingDestinationKindValues.QUEUE);
expect(
span.attributes[SemanticAttributes.MESSAGING_DESTINATION]
).toEqual('otel-demo-aws-sdk');
expect(span.attributes[SemanticAttributes.MESSAGING_URL]).toEqual(
params.QueueUrl
);
expect(span.attributes[SemanticAttributes.HTTP_STATUS_CODE]).toEqual(
200
);
});

it('sqs receive add messaging attributes and context', done => {
nock(`https://sqs.${region}.amazonaws.com/`)
.post('/')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0"?><SendMessageBatchResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"><SendMessageBatchResult><SendMessageBatchResultEntry><Id>1000</Id><MessageId>57f7be0d-22a2-42f4-a9d9-3a136fbb219d</MessageId><MD5OfMessageBody>c1fa3d847ec219eeb524250e0498b614</MD5OfMessageBody></SendMessageBatchResultEntry><SendMessageBatchResultEntry><Id>1001</Id><MessageId>fee3d5ba-32f1-48b9-a4bc-8a6ef6d4457c</MessageId><MD5OfMessageBody>3e83b83eef8cece2b95bfc8b9501da0a</MD5OfMessageBody></SendMessageBatchResultEntry></SendMessageBatchResult><ResponseMetadata><RequestId>fcd31105-ac68-55d8-829e-4ba2483ac308</RequestId></ResponseMetadata></SendMessageBatchResponse>

0 comments on commit 8a90e78

Please sign in to comment.