Skip to content

Commit e0722a0

Browse files
committed
Refactor and format lambda handler tests
1 parent 127d62a commit e0722a0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

plugins/node/opentelemetry-instrumentation-aws-lambda/test/integrations/lambda-handler.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
ReadableSpan,
3131
} from '@opentelemetry/sdk-trace-base';
3232
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
33-
import { APIGatewayProxyEvent, Context, SQSEvent } from 'aws-lambda';
33+
import { Context } from 'aws-lambda';
3434
import * as assert from 'assert';
3535
import {
3636
ATTR_URL_FULL,
@@ -833,7 +833,7 @@ describe('lambda handler', () => {
833833
initializeHandler('lambda-test/sync.sqshandler');
834834
const producerTraceId = '1df415edd0ad7f83e573f6504381dcec';
835835
const producerSpanId = '83b7424a259945cb';
836-
const event = {
836+
const sqsEvent = {
837837
Records: [
838838
{
839839
messageAttributes: {
@@ -849,11 +849,14 @@ describe('lambda handler', () => {
849849
],
850850
};
851851

852-
await lambdaRequire('lambda-test/sync').sqshandler(event, ctx, () => {});
852+
await lambdaRequire('lambda-test/sync').sqshandler(
853+
sqsEvent,
854+
ctx,
855+
() => {}
856+
);
853857
const spans = memoryExporter.getFinishedSpans();
854858

855859
assert.strictEqual(spans.length, 2);
856-
857860
assert.equal(
858861
spans[0].parentSpanContext?.traceId,
859862
spans[1].spanContext().traceId
@@ -862,7 +865,6 @@ describe('lambda handler', () => {
862865
spans[0].parentSpanContext?.spanId,
863866
spans[1].spanContext().spanId
864867
);
865-
866868
assert.equal(spans[0].links[0]?.context.traceId, producerTraceId);
867869
assert.equal(spans[0].links[0].context.spanId, producerSpanId);
868870
});
@@ -873,7 +875,7 @@ describe('lambda handler', () => {
873875
initializeHandler('lambda-test/async.sqshandler');
874876
const producerTraceId = '1df415edd0ad7f83e573f6504381dcec';
875877
const producerSpanId = '83b7424a259945cb';
876-
const event = {
878+
const sqsEvent = {
877879
Records: [
878880
{
879881
messageAttributes: {
@@ -889,7 +891,7 @@ describe('lambda handler', () => {
889891
],
890892
};
891893

892-
await lambdaRequire('lambda-test/async').sqshandler(event, ctx);
894+
await lambdaRequire('lambda-test/async').sqshandler(sqsEvent, ctx);
893895
const spans = memoryExporter.getFinishedSpans();
894896

895897
assert.strictEqual(spans.length, 2);

0 commit comments

Comments
 (0)