Skip to content

Commit 450a1c2

Browse files
committed
remove tests for end-of-life aws-sdk v2, fix kinesis test latency
1 parent 1a69e09 commit 450a1c2

File tree

5 files changed

+23
-110
lines changed

5 files changed

+23
-110
lines changed

package-lock.json

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"@aws-sdk/client-sns": "3.85.0",
5959
"@aws-sdk/client-sqs": "3.85.0",
6060
"@aws-sdk/types": "3.78.0",
61+
"@smithy/node-http-handler": "2.4.0",
6162
"@opentelemetry/api": "^1.3.0",
6263
"@opentelemetry/contrib-test-utils": "^0.41.0",
6364
"@opentelemetry/sdk-trace-base": "^1.8.0",

plugins/node/opentelemetry-instrumentation-aws-sdk/test/kinesis.test.ts

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { AttributeNames } from '../src/enums';
2323
registerInstrumentationTesting(new AwsInstrumentation());
2424

2525
import { DescribeStreamCommand, KinesisClient } from '@aws-sdk/client-kinesis';
26-
import * as AWS from 'aws-sdk';
27-
import { AWSError } from 'aws-sdk';
26+
import { NodeHttpHandler } from '@smithy/node-http-handler';
27+
import * as fs from 'fs';
2828
import * as nock from 'nock';
2929

3030
import { SpanKind } from '@opentelemetry/api';
@@ -33,66 +33,31 @@ import { expect } from 'expect';
3333

3434
const region = 'us-east-1';
3535

36-
describe('Kinesis - v2', () => {
37-
let kinesis: AWS.Kinesis;
38-
beforeEach(() => {
39-
AWS.config.credentials = {
40-
accessKeyId: 'test key id',
41-
expired: false,
42-
expireTime: new Date(),
43-
secretAccessKey: 'test acc key',
44-
sessionToken: 'test token',
45-
};
46-
});
47-
48-
describe('DescribeStream', () => {
49-
it('adds Stream Name', async () => {
50-
kinesis = new AWS.Kinesis({ region: region });
51-
const dummyStreamName = 'dummy-stream-name';
52-
53-
nock(`https://kinesis.${region}.amazonaws.com`)
54-
.get('/')
55-
.reply(200, 'null');
56-
57-
await kinesis
58-
.describeStream(
59-
{
60-
StreamName: dummyStreamName,
61-
},
62-
(err: AWSError) => {
63-
expect(err).toBeFalsy();
64-
}
65-
)
66-
.promise();
67-
68-
const testSpans = getTestSpans();
69-
const describeSpans = testSpans.filter((s: ReadableSpan) => {
70-
return s.name === 'Kinesis.DescribeStream';
71-
});
72-
expect(describeSpans.length).toBe(1);
73-
const describeSpan = describeSpans[0];
74-
expect(
75-
describeSpan.attributes[AttributeNames.AWS_KINESIS_STREAM_NAME]
76-
).toBe(dummyStreamName);
77-
expect(describeSpan.kind).toBe(SpanKind.CLIENT);
78-
});
79-
});
80-
});
81-
8236
describe('Kinesis - v3', () => {
8337
describe('DescribeStream', () => {
84-
it('adds Stream Name', async () => {
38+
it('Request span attributes - adds Stream Name', async () => {
8539
const dummyStreamName = 'dummy-stream-name';
8640

87-
nock(`https://kinesis.${region}.amazonaws.com/`)
41+
nock(`https://kinesis.${region}.amazonaws.com`)
8842
.post('/')
89-
.reply(200, 'null');
43+
.reply(
44+
200,
45+
fs.readFileSync(
46+
'./test/mock-responses/kinesis-describe-stream.json',
47+
'utf8'
48+
)
49+
);
9050

9151
const params = {
9252
StreamName: dummyStreamName,
9353
};
94-
const client = new KinesisClient({ region });
95-
await client.send(new DescribeStreamCommand(params)).catch(() => {});
54+
55+
// Use NodeHttpHandler to use HTTP instead of HTTP2 because nock does not support HTTP2
56+
const client = new KinesisClient({
57+
region: region,
58+
requestHandler: new NodeHttpHandler(),
59+
});
60+
await client.send(new DescribeStreamCommand(params));
9661

9762
const testSpans: ReadableSpan[] = getTestSpans();
9863
const describeSpans: ReadableSpan[] = testSpans.filter(
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"StreamDescription":{"EncryptionType":"NONE","EnhancedMonitoring":[{"ShardLevelMetrics":[]}],"HasMoreShards":false,"RetentionPeriodHours":24,"Shards":[{"HashKeyRange":{"EndingHashKey":"113238940823489329203432849230874303284","StartingHashKey":"0"},"SequenceNumberRange":{"StartingSequenceNumber":"43987583475293457385930053489574375382543783454534789435"},"ShardId":"shardId-000000000000"},{"HashKeyRange":{"EndingHashKey":"226854911280625642308916401214512140969","StartingHashKey":"113427455579312821154458202477256070485"},"SequenceNumberRange":{"StartingSequenceNumber":"49654869303348141538950437146463849462533012903803486226"},"ShardId":"shardId-000000000001"},{"HashKeyRange":{"EndingHashKey":"340282366920284953463374607431768211455","StartingHashKey":"226854911280625642308916382954512140970"},"SequenceNumberRange":{"StartingSequenceNumber":"49654869303370442228501967769610713180805661265309466658"},"ShardId":"shardId-000000000002"}],"StreamARN":"arn:aws:kinesis:us-east-1:123456789012:stream/dummy-stream-name","StreamCreationTimestamp":1.723630733E9,"StreamModeDetails":{"StreamMode":"PROVISIONED"},"StreamName":"dummy-stream-name","StreamStatus":"ACTIVE"}}

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

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import { AttributeNames } from '../src/enums';
2323
registerInstrumentationTesting(new AwsInstrumentation());
2424

2525
import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
26-
import * as AWS from 'aws-sdk';
27-
import { AWSError } from 'aws-sdk';
2826
import * as fs from 'fs';
2927
import * as nock from 'nock';
3028

@@ -34,53 +32,9 @@ import { expect } from 'expect';
3432

3533
const region = 'us-east-1';
3634

37-
describe('S3 - v2', () => {
38-
let s3: AWS.S3;
39-
beforeEach(() => {
40-
AWS.config.credentials = {
41-
accessKeyId: 'test key id',
42-
expired: false,
43-
expireTime: new Date(),
44-
secretAccessKey: 'test acc key',
45-
sessionToken: 'test token',
46-
};
47-
});
48-
49-
describe('ListObjects', () => {
50-
it('adds bucket Name', async () => {
51-
s3 = new AWS.S3({ region: region });
52-
const dummyBucketName = 'dummy-bucket-name';
53-
54-
nock(`https://s3.${region}.amazonaws.com`).get('/').reply(200, 'null');
55-
56-
await s3
57-
.listObjects(
58-
{
59-
Bucket: dummyBucketName,
60-
},
61-
(err: AWSError) => {
62-
expect(err).toBeFalsy();
63-
}
64-
)
65-
.promise();
66-
67-
const testSpans = getTestSpans();
68-
const listObjectsSpans = testSpans.filter((s: ReadableSpan) => {
69-
return s.name === 'S3.ListObjects';
70-
});
71-
expect(listObjectsSpans.length).toBe(1);
72-
const listObjectsSpan = listObjectsSpans[0];
73-
expect(listObjectsSpan.attributes[AttributeNames.AWS_S3_BUCKET]).toBe(
74-
dummyBucketName
75-
);
76-
expect(listObjectsSpan.kind).toBe(SpanKind.CLIENT);
77-
});
78-
});
79-
});
80-
8135
describe('S3 - v3', () => {
8236
describe('PutObject', () => {
83-
it('adds bucket Name', async () => {
37+
it('Request span attributes - adds bucket Name', async () => {
8438
const dummyBucketName = 'ot-demo-test';
8539

8640
nock(`https://${dummyBucketName}.s3.${region}.amazonaws.com/`)

0 commit comments

Comments
 (0)