Skip to content

Commit

Permalink
Test processing-span attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
harelmo-lumigo committed Mar 7, 2024
1 parent 4b3cd2d commit bd6bcc4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentations/@aws-sdk/client-sqs/aws-sdk-v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('/', '-')
Expand Down Expand Up @@ -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)
}
)

Expand Down
5 changes: 4 additions & 1 deletion test/instrumentations/aws-sdk/app/aws-sdk-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions test/instrumentations/aws-sdk/aws-sdk-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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)
}
)

Expand Down

0 comments on commit bd6bcc4

Please sign in to comment.