diff --git a/test/instrumentations/@aws-sdk/client-sqs/app/aws-sdk-client-sqs-app.js b/test/instrumentations/@aws-sdk/client-sqs/app/aws-sdk-client-sqs-app.js index 1c2d3565..4bd3f3c8 100644 --- a/test/instrumentations/@aws-sdk/client-sqs/app/aws-sdk-client-sqs-app.js +++ b/test/instrumentations/@aws-sdk/client-sqs/app/aws-sdk-client-sqs-app.js @@ -34,7 +34,10 @@ const requestListener = async function (req, res) { QueueUrl: requestUrl.query.queueUrl, MaxNumberOfMessages: 1 }) - await sqsClient.send(receiveMessageCommand) + const { Messages } = await sqsClient.send(receiveMessageCommand) + + // Triggers an aws-sdk processing-span + await Promise.all(Messages.map(() => console.log('processing message!'))) respond(res, 200, {}); } catch (err) { console.error('Error on receiveMessage', err); diff --git a/test/instrumentations/@aws-sdk/client-sqs/aws-sdk-v3.test.ts b/test/instrumentations/@aws-sdk/client-sqs/aws-sdk-v3.test.ts index 815a5f2f..6a7e039f 100644 --- a/test/instrumentations/@aws-sdk/client-sqs/aws-sdk-v3.test.ts +++ b/test/instrumentations/@aws-sdk/client-sqs/aws-sdk-v3.test.ts @@ -12,6 +12,7 @@ import 'jest-json'; import { getSpansByAttribute } from '../../../utils/spans'; import { createTempQueue, filterAwsSdkInstrumentationSpans, testAppQueryParams } from '../../../utils/aws-sdk-helpers'; import { shouldSkipSpanExport } from '../../../../src/resources/spanProcessor' +import { SpanKind } from '@opentelemetry/api'; const INSTRUMENTATION_NAME = '@aws-sdk/client-sqs'; const INSTRUMENTATION_SPANS_FILE_PREFIX = INSTRUMENTATION_NAME.replace('/', '-') @@ -137,6 +138,10 @@ describe.each(versionsToTest(INSTRUMENTATION_NAME, INSTRUMENTATION_NAME))(`Instr } ] }); + + const processingSpans = getSpansByAttribute(spans, "messaging.operation", "process") + expect(processingSpans.length).toBeGreaterThanOrEqual(1) + expect(processingSpans).toSatisfyAll((span) => span.kind === SpanKind.INTERNAL && span.attributes['messaging.message_id'] === undefined) } ) diff --git a/test/instrumentations/aws-sdk/app/aws-sdk-app.js b/test/instrumentations/aws-sdk/app/aws-sdk-app.js index cbcae9e8..16ceda5c 100644 --- a/test/instrumentations/aws-sdk/app/aws-sdk-app.js +++ b/test/instrumentations/aws-sdk/app/aws-sdk-app.js @@ -25,10 +25,13 @@ const requestListener = async function (req, res) { console.log('/sqs/receive endpoint invoked, query-params: ', JSON.stringify(requestUrl.query)); try { sqsClient = new AWS.SQS({ endpoint: `http://localhost:${requestUrl.query.sqsPort}`, region: requestUrl.query.region }); - await sqsClient.receiveMessage({ + const { Messages } = await sqsClient.receiveMessage({ QueueUrl: requestUrl.query.queueUrl, MaxNumberOfMessages: 1 }).promise() + + // Triggers an aws-sdk processing-span + await Promise.all(Messages.map(() => console.log('processing message!'))) respond(res, 200, {}); } catch (err) { console.error('Error on receiveMessage', err); diff --git a/test/instrumentations/aws-sdk/aws-sdk-v2.test.ts b/test/instrumentations/aws-sdk/aws-sdk-v2.test.ts index 2892b213..311cf398 100644 --- a/test/instrumentations/aws-sdk/aws-sdk-v2.test.ts +++ b/test/instrumentations/aws-sdk/aws-sdk-v2.test.ts @@ -12,6 +12,7 @@ import 'jest-json'; import { getSpansByAttribute } from '../../utils/spans'; import { createTempQueue, filterAwsSdkInstrumentationSpans, testAppQueryParams } from '../../utils/aws-sdk-helpers'; import { shouldSkipSpanExport } from '../../../src/resources/spanProcessor'; +import { SpanKind } from '@opentelemetry/api'; const INSTRUMENTATION_NAME = 'aws-sdk'; const SPANS_DIR = join(__dirname, 'spans'); @@ -135,6 +136,10 @@ describe.each(versionsToTest(INSTRUMENTATION_NAME, INSTRUMENTATION_NAME))(`Instr } ] }); + + const processingSpans = getSpansByAttribute(spans, "messaging.operation", "process") + expect(processingSpans.length).toBeGreaterThanOrEqual(1) + expect(processingSpans).toSatisfyAll((span) => span.kind === SpanKind.INTERNAL && span.attributes['messaging.message_id'] === undefined) } )