Skip to content

Commit 8e08755

Browse files
authored
test(instrumentation-aws-sdk): update devDeps to modern version of instrumented packages (#2723)
This flips the usage of 'npm test' and 'npm run test-all-versions' so that the former uses recent versions of the instrumented packages. This allows updating devDeps to the latest. 'npm test' will skip tests for older versions of node that aren't supported by the latest version of the instrumented packages. Testing all the old versions (of node and instrumented packages) is left to 'npm run test-all-versions' (TAV). Refs: #2722
1 parent 4b51e60 commit 8e08755

File tree

8 files changed

+3414
-4468
lines changed

8 files changed

+3414
-4468
lines changed

package-lock.json

Lines changed: 3079 additions & 4256 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# Note: tests must set `SKIP_TEST_IF_DISABLE=true` to override usage of
2+
# `mocha --require '../../../scripts/skip-test-if.js' ...` if calling `npm test`.
3+
14
"aws-sdk":
5+
env:
6+
- SKIP_TEST_IF_DISABLE=true
27
# A small subset of releases in the range [2.308.0, 3) to reduce testing time.
38
versions:
49
include: "^2.308.0"
510
mode: max-7
611
commands:
7-
- npm run test
12+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v2.test.ts
813

914
# Versions [3.363.0, 3.377.0] of all @aws-sdk/client-* were bad releases. See:
1015
# - https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2464#issuecomment-2403652552
@@ -15,44 +20,61 @@
1520
# - 16.x dropped in v3.723.0 https://github.com/aws/aws-sdk-js-v3/pull/6775
1621

1722
"@aws-sdk/client-s3":
23+
env:
24+
- SKIP_TEST_IF_DISABLE=true
1825
# - 3.529.0 was missing the fast-xml-parser dependency (https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.529.1)
1926
jobs:
2027
- node: ">=18"
2128
versions:
2229
include: "^3.6.1"
2330
exclude: "3.529.0 || >=3.363.0 <=3.377.0"
2431
mode: "max-7"
25-
commands: npm run test
32+
commands:
33+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v3-s3.test.ts
34+
- mocha --require '@opentelemetry/contrib-test-utils' test/s3.test.ts
2635
- node: "16"
2736
versions:
2837
include: ">=3.6.1 <3.723.0"
2938
exclude: "3.529.0 || >=3.363.0 <=3.377.0"
3039
mode: "max-7"
31-
commands: npm run test
40+
commands:
41+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v3-s3.test.ts
42+
- mocha --require '@opentelemetry/contrib-test-utils' test/s3.test.ts
3243
- node: "14"
3344
versions:
3445
include: ">=3.6.1 <3.567.0"
3546
exclude: "3.529.0 || >=3.363.0 <=3.377.0"
3647
mode: "max-7"
37-
commands: npm run test
48+
commands:
49+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v3-s3.test.ts
50+
- mocha --require '@opentelemetry/contrib-test-utils' test/s3.test.ts
3851

3952
"@aws-sdk/client-sqs":
53+
env:
54+
- SKIP_TEST_IF_DISABLE=true
4055
jobs:
4156
- node: ">=18"
4257
versions:
4358
include: "^3.24.0"
4459
exclude: ">=3.363.0 <=3.377.0"
4560
mode: "max-7"
46-
commands: npm run test
61+
commands:
62+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v3-sqs.test.ts
63+
- mocha --require '@opentelemetry/contrib-test-utils' test/sqs.test.ts
4764
- node: "16"
4865
versions:
4966
include: ">=3.24.0 <3.723.0"
5067
exclude: ">=3.363.0 <=3.377.0"
5168
mode: "max-7"
52-
commands: npm run test
69+
commands:
70+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v3-sqs.test.ts
71+
- mocha --require '@opentelemetry/contrib-test-utils' test/sqs.test.ts
5372
- node: "14"
5473
versions:
5574
include: ">=3.24.0 <3.567.0"
5675
exclude: ">=3.363.0 <=3.377.0"
5776
mode: "max-7"
58-
commands: npm run test
77+
commands:
78+
- mocha --require '@opentelemetry/contrib-test-utils' test/aws-sdk-v3-sqs.test.ts
79+
- mocha --require '@opentelemetry/contrib-test-utils' test/sqs.test.ts
80+

plugins/node/opentelemetry-instrumentation-aws-sdk/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"prewatch": "npm run precompile",
3636
"prepublishOnly": "npm run compile",
3737
"tdd": "npm run test -- --watch-extensions ts --watch",
38-
"test": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'",
38+
"test": "SKIP_TEST_IF_NODE_OLDER_THAN=18 nyc mocha --require '../../../scripts/skip-test-if.js' --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'",
3939
"test-all-versions": "tav",
4040
"version:update": "node ../../../scripts/version-update.js",
4141
"watch": "tsc -w"
@@ -50,13 +50,13 @@
5050
"@opentelemetry/semantic-conventions": "^1.27.0"
5151
},
5252
"devDependencies": {
53-
"@aws-sdk/client-dynamodb": "3.85.0",
54-
"@aws-sdk/client-kinesis": "3.85.0",
55-
"@aws-sdk/client-lambda": "3.85.0",
56-
"@aws-sdk/client-s3": "3.85.0",
57-
"@aws-sdk/client-sns": "3.85.0",
58-
"@aws-sdk/client-sqs": "3.85.0",
59-
"@aws-sdk/types": "3.78.0",
53+
"@aws-sdk/client-dynamodb": "^3.85.0",
54+
"@aws-sdk/client-kinesis": "^3.85.0",
55+
"@aws-sdk/client-lambda": "^3.85.0",
56+
"@aws-sdk/client-s3": "^3.85.0",
57+
"@aws-sdk/client-sns": "^3.85.0",
58+
"@aws-sdk/client-sqs": "^3.85.0",
59+
"@aws-sdk/types": "^3.370.0",
6060
"@opentelemetry/api": "^1.3.0",
6161
"@opentelemetry/contrib-test-utils": "^0.45.1",
6262
"@opentelemetry/sdk-trace-base": "^1.8.0",

plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts renamed to plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3-s3.test.ts

Lines changed: 3 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
import {
1718
AwsInstrumentation,
1819
AwsSdkRequestHookInformation,
@@ -31,26 +32,16 @@ import {
3132
S3,
3233
S3Client,
3334
} from '@aws-sdk/client-s3';
34-
import { SQS } from '@aws-sdk/client-sqs';
3535
import { SpanKind } from '@opentelemetry/api';
3636

3737
// set aws environment variables, so tests in non aws environment are able to run
3838
process.env.AWS_ACCESS_KEY_ID = 'testing';
3939
process.env.AWS_SECRET_ACCESS_KEY = 'testing';
4040

4141
import 'mocha';
42-
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
43-
import { context, SpanStatusCode, trace, Span } from '@opentelemetry/api';
42+
import { SpanStatusCode, Span } from '@opentelemetry/api';
4443
import {
45-
MESSAGINGDESTINATIONKINDVALUES_QUEUE,
46-
MESSAGINGOPERATIONVALUES_RECEIVE,
4744
SEMATTRS_HTTP_STATUS_CODE,
48-
SEMATTRS_MESSAGING_DESTINATION,
49-
SEMATTRS_MESSAGING_DESTINATION_KIND,
50-
SEMATTRS_MESSAGING_MESSAGE_ID,
51-
SEMATTRS_MESSAGING_OPERATION,
52-
SEMATTRS_MESSAGING_SYSTEM,
53-
SEMATTRS_MESSAGING_URL,
5445
SEMATTRS_RPC_METHOD,
5546
SEMATTRS_RPC_SERVICE,
5647
SEMATTRS_RPC_SYSTEM,
@@ -62,7 +53,7 @@ import * as nock from 'nock';
6253

6354
const region = 'us-east-1';
6455

65-
describe('instrumentation-aws-sdk-v3', () => {
56+
describe('instrumentation-aws-sdk-v3 (client-s3)', () => {
6657
const s3Client = new S3({ region });
6758

6859
describe('functional', () => {
@@ -285,189 +276,4 @@ describe('instrumentation-aws-sdk-v3', () => {
285276
});
286277
});
287278
});
288-
289-
describe('custom service behavior', () => {
290-
describe('SQS', () => {
291-
const sqsClient = new SQS({ region });
292-
293-
it('sqs send add messaging attributes', async () => {
294-
nock(`https://sqs.${region}.amazonaws.com/`)
295-
.matchHeader('content-type', 'application/x-www-form-urlencoded')
296-
.post('/')
297-
.reply(
298-
200,
299-
fs.readFileSync('./test/mock-responses/sqs-send.xml', 'utf8')
300-
);
301-
// @aws-sdk/client-sqs >=3.446.0 uses a new JSON protocol.
302-
nock(`https://sqs.${region}.amazonaws.com/`)
303-
.matchHeader('content-type', 'application/x-amz-json-1.0')
304-
.post('/')
305-
.reply(
306-
200,
307-
fs.readFileSync('./test/mock-responses/sqs-send.json', 'utf8')
308-
);
309-
310-
const params = {
311-
QueueUrl:
312-
'https://sqs.us-east-1.amazonaws.com/731241200085/otel-demo-aws-sdk',
313-
MessageBody: 'payload example from v3 without batch',
314-
};
315-
const response = await sqsClient.sendMessage(params);
316-
expect(getTestSpans().length).toBe(1);
317-
const [span] = getTestSpans();
318-
319-
// make sure we have the general aws attributes:
320-
expect(span.attributes[SEMATTRS_RPC_SYSTEM]).toEqual('aws-api');
321-
expect(span.attributes[SEMATTRS_RPC_METHOD]).toEqual('SendMessage');
322-
expect(span.attributes[SEMATTRS_RPC_SERVICE]).toEqual('SQS');
323-
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
324-
325-
// custom messaging attributes
326-
expect(span.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual('aws.sqs');
327-
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toEqual(
328-
MESSAGINGDESTINATIONKINDVALUES_QUEUE
329-
);
330-
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual(
331-
'otel-demo-aws-sdk'
332-
);
333-
expect(span.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
334-
params.QueueUrl
335-
);
336-
expect(span.attributes[SEMATTRS_MESSAGING_MESSAGE_ID]).toEqual(
337-
response.MessageId
338-
);
339-
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
340-
});
341-
342-
it('sqs send message batch attributes', async () => {
343-
nock(`https://sqs.${region}.amazonaws.com/`)
344-
.matchHeader('content-type', 'application/x-www-form-urlencoded')
345-
.post('/')
346-
.reply(
347-
200,
348-
fs.readFileSync('./test/mock-responses/sqs-send-batch.xml', 'utf8')
349-
);
350-
nock(`https://sqs.${region}.amazonaws.com/`)
351-
.matchHeader('content-type', 'application/x-amz-json-1.0')
352-
.post('/')
353-
.reply(
354-
200,
355-
fs.readFileSync('./test/mock-responses/sqs-send-batch.json', 'utf8')
356-
);
357-
358-
const params = {
359-
QueueUrl:
360-
'https://sqs.us-east-1.amazonaws.com/731241200085/otel-demo-aws-sdk',
361-
MessageBody: 'payload example from v3 without batch',
362-
Entries: [
363-
{
364-
Id: '1000',
365-
MessageBody: 'msg body for 1000',
366-
},
367-
{
368-
Id: '1001',
369-
MessageBody: 'msg body for 1001',
370-
},
371-
],
372-
};
373-
await sqsClient.sendMessageBatch(params);
374-
expect(getTestSpans().length).toBe(1);
375-
const [span] = getTestSpans();
376-
377-
// make sure we have the general aws attributes:
378-
expect(span.attributes[SEMATTRS_RPC_SYSTEM]).toEqual('aws-api');
379-
expect(span.attributes[SEMATTRS_RPC_METHOD]).toEqual(
380-
'SendMessageBatch'
381-
);
382-
expect(span.attributes[SEMATTRS_RPC_SERVICE]).toEqual('SQS');
383-
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
384-
385-
// messaging semantic attributes
386-
expect(span.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual('aws.sqs');
387-
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION_KIND]).toEqual(
388-
MESSAGINGDESTINATIONKINDVALUES_QUEUE
389-
);
390-
expect(span.attributes[SEMATTRS_MESSAGING_DESTINATION]).toEqual(
391-
'otel-demo-aws-sdk'
392-
);
393-
expect(span.attributes[SEMATTRS_MESSAGING_URL]).toEqual(
394-
params.QueueUrl
395-
);
396-
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
397-
});
398-
399-
it('sqs receive add messaging attributes', done => {
400-
nock(`https://sqs.${region}.amazonaws.com/`)
401-
.matchHeader('content-type', 'application/x-www-form-urlencoded')
402-
.post('/')
403-
.reply(
404-
200,
405-
fs.readFileSync('./test/mock-responses/sqs-receive.xml', 'utf8')
406-
);
407-
nock(`https://sqs.${region}.amazonaws.com/`)
408-
.matchHeader('content-type', 'application/x-amz-json-1.0')
409-
.post('/')
410-
.reply(
411-
200,
412-
fs.readFileSync('./test/mock-responses/sqs-receive.json', 'utf8')
413-
);
414-
415-
const params = {
416-
QueueUrl:
417-
'https://sqs.us-east-1.amazonaws.com/731241200085/otel-demo-aws-sdk',
418-
MaxNumberOfMessages: 3,
419-
};
420-
sqsClient.receiveMessage(params).then(res => {
421-
expect(getTestSpans().length).toBe(1);
422-
const [span] = getTestSpans();
423-
424-
// make sure we have the general aws attributes:
425-
expect(span.attributes[SEMATTRS_RPC_SYSTEM]).toEqual('aws-api');
426-
expect(span.attributes[SEMATTRS_RPC_METHOD]).toEqual(
427-
'ReceiveMessage'
428-
);
429-
expect(span.attributes[SEMATTRS_RPC_SERVICE]).toEqual('SQS');
430-
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
431-
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
432-
done();
433-
});
434-
});
435-
436-
// Propagating span context to SQS ReceiveMessage promise handler is
437-
// broken with `@aws-sdk/client-sqs` v3.316.0 and later.
438-
// https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1477
439-
it.skip('sqs receive context', done => {
440-
nock(`https://sqs.${region}.amazonaws.com/`)
441-
.matchHeader('content-type', 'application/x-www-form-urlencoded')
442-
.post('/')
443-
.reply(
444-
200,
445-
fs.readFileSync('./test/mock-responses/sqs-receive.xml', 'utf8')
446-
);
447-
nock(`https://sqs.${region}.amazonaws.com/`)
448-
.matchHeader('content-type', 'application/x-amz-json-1.0')
449-
.post('/')
450-
.reply(
451-
200,
452-
fs.readFileSync('./test/mock-responses/sqs-receive.json', 'utf8')
453-
);
454-
455-
const params = {
456-
QueueUrl:
457-
'https://sqs.us-east-1.amazonaws.com/731241200085/otel-demo-aws-sdk',
458-
MaxNumberOfMessages: 3,
459-
};
460-
sqsClient.receiveMessage(params).then(res => {
461-
const receiveCallbackSpan = trace.getSpan(context.active());
462-
expect(receiveCallbackSpan).toBeDefined();
463-
const attributes = (receiveCallbackSpan as unknown as ReadableSpan)
464-
.attributes;
465-
expect(attributes[SEMATTRS_MESSAGING_OPERATION]).toMatch(
466-
MESSAGINGOPERATIONVALUES_RECEIVE
467-
);
468-
done();
469-
});
470-
});
471-
});
472-
});
473279
});

0 commit comments

Comments
 (0)