Repository: serverless/dashboard (language: python)

Issue:
SDK Schema: Release v0.5.0



Discussion / hints:

Fix patch:
diff --git a/node/packages/aws-lambda-sdk/docs/sdk-trace.md b/node/packages/aws-lambda-sdk/docs/sdk-trace.md
index 0d247a080..3a0f17a67 100644
--- a/node/packages/aws-lambda-sdk/docs/sdk-trace.md
+++ b/node/packages/aws-lambda-sdk/docs/sdk-trace.md
@@ -51,6 +51,23 @@ Tags set in case of `'error:handled'` outcome
 | `aws.lambda.error_exception_message`    | Error message     |
 | `aws.lambda.error_exception_stacktrace` | Error stack trace |
 
+##### HTTP Endpoint
+
+Tags collected if event is sourced by either:
+
+- AWS API Gateway v1 REST API endpoint configured with `AWS_PROXY` integration type.
+- AWS API Gateway v2 HTTP API endpoint configured with either v1 or v2 version of a payload
+
+| Name                          | Value                                                           |
+| ----------------------------- | --------------------------------------------------------------- |
+| `aws.lambda.http.method`      | Request method                                                  |
+| `aws.lambda.http.protocol`    | Endpoint protocol (e.g. `HTTP/1.1`)                             |
+| `aws.lambda.http.host`        | Endpoint Domain name                                            |
+| `aws.lambda.http.path`        | Request path                                                    |
+| `aws.lambda.http.query`       | Query parameters as query string (e.g. `foo=bar&query=string`)  |
+| `aws.lambda.http.status_code` | Response status code                                            |
+| `aws.lambda.http.error_code`  | Filled, if no or invalid status code is provided by the handler |
+
 ##### AWS API Gateway
 
 Tags collected if event is sourced by either:
@@ -58,20 +75,17 @@ Tags collected if event is sourced by either:
 - AWS API Gateway v1 REST API endpoint configured with `AWS_PROXY` integration type.
 - AWS API Gateway v2 HTTP API endpoint configured with either v1 or v2 version of a payload
 
-| Name                                                     | Value                                                                               |
-| -------------------------------------------------------- | ----------------------------------------------------------------------------------- |
-| `aws.lambda.api_gateway.account_id`                      | Account id of API Gateway                                                           |
-| `aws.lambda.api_gateway.api_id`                          | API id                                                                              |
-| `aws.lambda.api_gateway.api_stage`                       | API stage                                                                           |
-| `aws.lambda.api_gateway.request.id`                      | API Gateway request id                                                              |
-| `aws.lambda.api_gateway.request.time_epoch`              | API Gateway request time                                                            |
-| `aws.lambda.api_gateway.request.protocol`                | Endpoint protocol (e.g. `HTTP/1.1`)                                                 |
-| `aws.lambda.api_gateway.request.domain`                  | Endpoint Domain name                                                                |
-| `aws.lambda.api_gateway.request.headers`                 | JSON string of request headers. Multi value headers are stored as arrays            |
-| `aws.lambda.api_gateway.request.method`                  | Request method                                                                      |
-| `aws.lambda.api_gateway.request.path`                    | Request path                                                                        |
-| `aws.lambda.api_gateway.request.path_parameters`         | JSON string of request path parameters                                              |
-| `aws.lambda.api_gateway.request.query_string_parameters` | JSON string of query string parameters. Multi value parameters are stored as arrays |
+| Name                                             | Value                                                                                 |
+| ------------------------------------------------ | ------------------------------------------------------------------------------------- |
+| `aws.lambda.event_source`                        | `"aws.apigateway"`                                                                    |
+| `aws.lambda.event_type`                          | `"aws.apigateway.rest"`, `"aws.apigatewayv2.http.v1"` or `"aws.apigatewayv2.http.v2"` |
+| `aws.lambda.api_gateway.account_id`              | Account id of API Gateway                                                             |
+| `aws.lambda.api_gateway.api_id`                  | API id                                                                                |
+| `aws.lambda.api_gateway.api_stage`               | API stage                                                                             |
+| `aws.lambda.api_gateway.request.id`              | API Gateway request id                                                                |
+| `aws.lambda.api_gateway.request.time_epoch`      | API Gateway request time                                                              |
+| `aws.lambda.api_gateway.request.headers`         | JSON string of request headers. Multi value headers are stored as arrays              |
+| `aws.lambda.api_gateway.request.path_parameters` | JSON string of request path parameters                                                |
 
 ##### SQS queue message
 
@@ -79,6 +93,8 @@ Tags collected if event is sourced by SQS queue
 
 | Name                         | Value                |
 | ---------------------------- | -------------------- |
+| `aws.lambda.event_source`    | `"aws.sqs"`          |
+| `aws.lambda.event_type`      | `"aws.sqs"`          |
 | `aws.lambda.sqs.queue_name`  | Queue name           |
 | `aws.lambda.sqs.message_ids` | Array of message ids |
 
@@ -88,6 +104,8 @@ Tags collected if event is sourced by SNS topic subscription
 
 | Name                         | Value                |
 | ---------------------------- | -------------------- |
+| `aws.lambda.event_source`    | `"aws.sns"`          |
+| `aws.lambda.event_type`      | `"aws.sns"`          |
 | `aws.lambda.sns.topic_name`  | Topic name           |
 | `aws.lambda.sns.message_ids` | Array of message ids |
 
diff --git a/node/packages/aws-lambda-sdk/instrument.js b/node/packages/aws-lambda-sdk/instrument.js
index f466664b7..b0cdf30fa 100644
--- a/node/packages/aws-lambda-sdk/instrument.js
+++ b/node/packages/aws-lambda-sdk/instrument.js
@@ -9,6 +9,7 @@ const coerceToString = require('type/string/coerce');
 const ensureString = require('type/string/ensure');
 const traceProto = require('@serverless/sdk-schema/dist/trace');
 const resolveEventTags = require('./lib/resolve-event-tags');
+const resolveResponseTags = require('./lib/resolve-response-tags');
 const pkgJson = require('./package');
 
 const serverlessSdk = global.serverlessSdk || require('./');
@@ -75,6 +76,8 @@ module.exports = (originalHandler, options = {}) => {
             awsLambdaSpan.tags.set('aws.lambda.error_exception_stacktrace', outcomeResult.stack);
           }
         }
+      } else {
+        resolveResponseTags(outcomeResult);
       }
 
       awsLambdaSpan.close();
diff --git a/node/packages/aws-lambda-sdk/lib/resolve-event-tags.js b/node/packages/aws-lambda-sdk/lib/resolve-event-tags.js
index d15797d30..5105b34ca 100644
--- a/node/packages/aws-lambda-sdk/lib/resolve-event-tags.js
+++ b/node/packages/aws-lambda-sdk/lib/resolve-event-tags.js
@@ -25,6 +25,19 @@ const resolveParametersJson = (multiValueParameters) => {
   return JSON.stringify(result);
 };
 
+const resolveQueryString = (queryParameters) => {
+  if (!queryParameters) return null;
+  const params = new URLSearchParams();
+  for (const [name, values] of Object.entries(queryParameters)) {
+    if (!Array.isArray(values)) {
+      params.append(name, values);
+      continue;
+    }
+    for (const value of values) params.append(name, value);
+  }
+  return params.toString();
+};
+
 const apiGatewayEventMap = [
   'resource',
   'path',
@@ -166,6 +179,13 @@ module.exports = (event) => {
   if (doesObjectMatchMap(event, apiGatewayEventMap)) {
     // API Gateway v1 REST API or v2 HTTP API (v1 payload) event
     const { requestContext } = event;
+    awsLambdaSpan.tags.setMany(
+      {
+        event_source: 'aws.apigateway',
+        event_type: event.version ? 'aws.apigatewayv2.http.v1' : 'aws.apigateway.rest',
+      },
+      { prefix: 'aws.lambda' }
+    );
     awsLambdaSpan.tags.setMany(
       {
         account_id: requestContext.accountId,
@@ -178,21 +198,30 @@ module.exports = (event) => {
       {
         id: requestContext.requestId,
         time_epoch: requestContext.requestTimeEpoch,
-        protocol: requestContext.protocol,
-        domain: requestContext.domainName,
         headers: resolveParametersJson(event.multiValueHeaders) || '{}',
-        method: requestContext.httpMethod,
-        path: requestContext.path,
         path_parameters: event.pathParameters ? JSON.stringify(event.pathParameters) : null,
-        query_string_parameters: resolveParametersJson(event.multiValueQueryStringParameters),
       },
       { prefix: 'aws.lambda.api_gateway.request' }
     );
+    awsLambdaSpan.tags.setMany(
+      {
+        method: requestContext.httpMethod,
+        protocol: requestContext.protocol,
+        host: requestContext.domainName,
+        path: requestContext.path,
+        query: resolveQueryString(event.multiValueQueryStringParameters),
+      },
+      { prefix: 'aws.lambda.http' }
+    );
     return;
   }
   if (doesObjectMatchMap(event, httpApiV2EventMap)) {
     // API Gateway v2 HTTP API (v2 payload) event
     const { requestContext } = event;
+    awsLambdaSpan.tags.setMany(
+      { event_source: 'aws.apigateway', event_type: 'aws.apigatewayv2.http.v2' },
+      { prefix: 'aws.lambda' }
+    );
     awsLambdaSpan.tags.setMany(
       {
         account_id: requestContext.accountId,
@@ -205,24 +234,31 @@ module.exports = (event) => {
       {
         id: requestContext.requestId,
         time_epoch: requestContext.timeEpoch,
-        protocol: requestContext.http.protocol,
-        domain: requestContext.domainName,
         headers: JSON.stringify(event.headers || {}),
-        method: requestContext.http.method,
-        path: requestContext.http.path,
         path_parameters: event.pathParameters ? JSON.stringify(event.pathParameters) : null,
-        query_string_parameters: event.queryStringParameters
-          ? JSON.stringify(event.queryStringParameters)
-          : null,
       },
       { prefix: 'aws.lambda.api_gateway.request' }
     );
+    awsLambdaSpan.tags.setMany(
+      {
+        method: requestContext.http.method,
+        protocol: requestContext.http.protocol,
+        host: requestContext.domainName,
+        path: requestContext.http.path,
+        query: resolveQueryString(event.queryStringParameters),
+      },
+      { prefix: 'aws.lambda.http' }
+    );
     return;
   }
 
   if (doesObjectMatchMap(event, sqsEventMap)) {
     // SQS Queue event
     const queueArn = event.Records[0].eventSourceARN;
+    awsLambdaSpan.tags.setMany(
+      { event_source: 'aws.sqs', event_type: 'aws.sqs' },
+      { prefix: 'aws.lambda' }
+    );
     awsLambdaSpan.tags.setMany(
       {
         queue_name: queueArn.slice(queueArn.lastIndexOf(':') + 1),
@@ -235,6 +271,10 @@ module.exports = (event) => {
   if (doesObjectMatchMap(event, snsEventMap)) {
     // SNS message
     const topicArn = event.Records[0].Sns.TopicArn;
+    awsLambdaSpan.tags.setMany(
+      { event_source: 'aws.sns', event_type: 'aws.sns' },
+      { prefix: 'aws.lambda' }
+    );
     awsLambdaSpan.tags.setMany(
       {
         topic_name: topicArn.slice(topicArn.lastIndexOf(':') + 1),
diff --git a/node/packages/aws-lambda-sdk/lib/resolve-response-tags.js b/node/packages/aws-lambda-sdk/lib/resolve-response-tags.js
new file mode 100644
index 000000000..91efc07f3
--- /dev/null
+++ b/node/packages/aws-lambda-sdk/lib/resolve-response-tags.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const coerceNaturalNumber = require('type/natural-number/coerce');
+
+const awsLambdaSpan = (global.serverlessSdk || require('../')).traceSpans.awsLambda;
+
+module.exports = (response) => {
+  switch (awsLambdaSpan.tags.get('aws.lambda.event_source')) {
+    case 'aws.apigateway':
+      {
+        let statusCode = response?.statusCode;
+        if (statusCode == null) {
+          awsLambdaSpan.tags.set('aws.lambda.http.error_code', 'MISSING_STATUS_CODE');
+          break;
+        }
+        if (typeof statusCode === 'string') statusCode = Number(statusCode);
+        if (
+          coerceNaturalNumber(statusCode) === statusCode &&
+          statusCode >= 100 &&
+          statusCode < 600
+        ) {
+          awsLambdaSpan.tags.set('aws.lambda.http.status_code', statusCode);
+        } else {
+          awsLambdaSpan.tags.set('aws.lambda.http.error_code', 'INVALID_STATUS_CODE');
+        }
+      }
+      break;
+    default:
+  }
+};
diff --git a/node/packages/aws-lambda-sdk/package.json b/node/packages/aws-lambda-sdk/package.json
index 20bbb0c4d..23742db58 100644
--- a/node/packages/aws-lambda-sdk/package.json
+++ b/node/packages/aws-lambda-sdk/package.json
@@ -4,7 +4,7 @@
   "version": "0.2.1",
   "author": "Serverless, Inc.",
   "dependencies": {
-    "@serverless/sdk-schema": "^0.4.0",
+    "@serverless/sdk-schema": "^0.5.0",
     "d": "^1.0.1",
     "ext": "^1.7.0",
     "long": "^5.2.0",


Test patch:
diff --git a/node/packages/aws-lambda-sdk/test/integration/index.test.js b/node/packages/aws-lambda-sdk/test/integration/index.test.js
index 2731a360d..e73cdca7f 100644
--- a/node/packages/aws-lambda-sdk/test/integration/index.test.js
+++ b/node/packages/aws-lambda-sdk/test/integration/index.test.js
@@ -195,6 +195,9 @@ describe('integration', function () {
                 for (const [, trace] of invocationsData.map((data) => data.trace).entries()) {
                   const { tags } = trace.spans[0];
 
+                  expect(tags['aws.lambda.event_source']).to.equal('aws.sqs');
+                  expect(tags['aws.lambda.event_type']).to.equal('aws.sqs');
+
                   expect(tags['aws.lambda.sqs.queue_name']).to.equal(testConfig.queueName);
                   expect(tags['aws.lambda.sqs.message_ids'].length).to.equal(1);
                 }
@@ -248,6 +251,9 @@ describe('integration', function () {
                 for (const [, trace] of invocationsData.map((data) => data.trace).entries()) {
                   const { tags } = trace.spans[0];
 
+                  expect(tags['aws.lambda.event_source']).to.equal('aws.sns');
+                  expect(tags['aws.lambda.event_type']).to.equal('aws.sns');
+
                   expect(tags['aws.lambda.sns.topic_name']).to.equal(testConfig.topicName);
                   expect(tags['aws.lambda.sns.message_ids'].length).to.equal(1);
                 }
@@ -386,20 +392,23 @@ describe('integration', function () {
                 for (const [, trace] of invocationsData.map((data) => data.trace).entries()) {
                   const { tags } = trace.spans[0];
 
+                  expect(tags['aws.lambda.event_source']).to.equal('aws.apigateway');
+                  expect(tags['aws.lambda.event_type']).to.equal('aws.apigateway.rest');
+
                   expect(tags).to.have.property('aws.lambda.api_gateway.account_id');
                   expect(tags['aws.lambda.api_gateway.api_id']).to.equal(testConfig.restApiId);
                   expect(tags['aws.lambda.api_gateway.api_stage']).to.equal('test');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.id');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.time_epoch');
-                  expect(tags).to.have.property('aws.lambda.api_gateway.request.domain');
+                  expect(tags).to.have.property('aws.lambda.http.host');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.headers');
-                  expect(tags['aws.lambda.api_gateway.request.method']).to.equal('POST');
-                  expect(tags['aws.lambda.api_gateway.request.path']).to.equal(
-                    '/test/some-path/some-param'
-                  );
+                  expect(tags['aws.lambda.http.method']).to.equal('POST');
+                  expect(tags['aws.lambda.http.path']).to.equal('/test/some-path/some-param');
                   expect(tags['aws.lambda.api_gateway.request.path_parameters']).to.equal(
                     JSON.stringify({ param: 'some-param' })
                   );
+
+                  expect(tags['aws.lambda.http.status_code']).to.equal(200);
                 }
               },
             },
@@ -437,15 +446,20 @@ describe('integration', function () {
                 for (const [, trace] of invocationsData.map((data) => data.trace).entries()) {
                   const { tags } = trace.spans[0];
 
+                  expect(tags['aws.lambda.event_source']).to.equal('aws.apigateway');
+                  expect(tags['aws.lambda.event_type']).to.equal('aws.apigatewayv2.http.v1');
+
                   expect(tags).to.have.property('aws.lambda.api_gateway.account_id');
                   expect(tags['aws.lambda.api_gateway.api_id']).to.equal(testConfig.apiId);
                   expect(tags['aws.lambda.api_gateway.api_stage']).to.equal('$default');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.id');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.time_epoch');
-                  expect(tags).to.have.property('aws.lambda.api_gateway.request.domain');
+                  expect(tags).to.have.property('aws.lambda.http.host');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.headers');
-                  expect(tags['aws.lambda.api_gateway.request.method']).to.equal('POST');
-                  expect(tags['aws.lambda.api_gateway.request.path']).to.equal('/test');
+                  expect(tags['aws.lambda.http.method']).to.equal('POST');
+                  expect(tags['aws.lambda.http.path']).to.equal('/test');
+
+                  expect(tags['aws.lambda.http.status_code']).to.equal(200);
                 }
               },
             },
@@ -483,15 +497,20 @@ describe('integration', function () {
                 for (const [, trace] of invocationsData.map((data) => data.trace).entries()) {
                   const { tags } = trace.spans[0];
 
+                  expect(tags['aws.lambda.event_source']).to.equal('aws.apigateway');
+                  expect(tags['aws.lambda.event_type']).to.equal('aws.apigatewayv2.http.v2');
+
                   expect(tags).to.have.property('aws.lambda.api_gateway.account_id');
                   expect(tags['aws.lambda.api_gateway.api_id']).to.equal(testConfig.apiId);
                   expect(tags['aws.lambda.api_gateway.api_stage']).to.equal('$default');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.id');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.time_epoch');
-                  expect(tags).to.have.property('aws.lambda.api_gateway.request.domain');
+                  expect(tags).to.have.property('aws.lambda.http.host');
                   expect(tags).to.have.property('aws.lambda.api_gateway.request.headers');
-                  expect(tags['aws.lambda.api_gateway.request.method']).to.equal('POST');
-                  expect(tags['aws.lambda.api_gateway.request.path']).to.equal('/test');
+                  expect(tags['aws.lambda.http.method']).to.equal('POST');
+                  expect(tags['aws.lambda.http.path']).to.equal('/test');
+
+                  expect(tags['aws.lambda.http.status_code']).to.equal(200);
                 }
               },
             },
diff --git a/node/packages/aws-lambda-sdk/test/unit/internal-extension/index.test.js b/node/packages/aws-lambda-sdk/test/unit/internal-extension/index.test.js
index 2962842af..e739824b9 100644
--- a/node/packages/aws-lambda-sdk/test/unit/internal-extension/index.test.js
+++ b/node/packages/aws-lambda-sdk/test/unit/internal-extension/index.test.js
@@ -182,6 +182,9 @@ describe('internal-extension/index.test.js', () => {
       },
     });
 
+    expect(tags.get('aws.lambda.event_source')).to.equal('aws.apigateway');
+    expect(tags.get('aws.lambda.event_type')).to.equal('aws.apigateway.rest');
+
     expect(tags.get('aws.lambda.api_gateway.account_id')).to.equal('205994128558');
     expect(tags.get('aws.lambda.api_gateway.api_id')).to.equal('xxx');
     expect(tags.get('aws.lambda.api_gateway.api_stage')).to.equal('test');
@@ -190,10 +193,8 @@ describe('internal-extension/index.test.js', () => {
       'da6c4e62-62c8-4693-8a4a-d6c4d943ddb4'
     );
     expect(tags.get('aws.lambda.api_gateway.request.time_epoch')).to.equal(1661872803090);
-    expect(tags.get('aws.lambda.api_gateway.request.protocol')).to.equal('HTTP/1.1');
-    expect(tags.get('aws.lambda.api_gateway.request.domain')).to.equal(
-      'xxx.execute-api.us-east-1.amazonaws.com'
-    );
+    expect(tags.get('aws.lambda.http.protocol')).to.equal('HTTP/1.1');
+    expect(tags.get('aws.lambda.http.host')).to.equal('xxx.execute-api.us-east-1.amazonaws.com');
     expect(tags.get('aws.lambda.api_gateway.request.headers')).to.equal(
       JSON.stringify({
         'Accept': '*/*',
@@ -201,17 +202,14 @@ describe('internal-extension/index.test.js', () => {
         'Other': ['First', 'Second'],
       })
     );
-    expect(tags.get('aws.lambda.api_gateway.request.method')).to.equal('POST');
-    expect(tags.get('aws.lambda.api_gateway.request.path')).to.equal('/test/some-path/some-param');
+    expect(tags.get('aws.lambda.http.method')).to.equal('POST');
+    expect(tags.get('aws.lambda.http.path')).to.equal('/test/some-path/some-param');
     expect(tags.get('aws.lambda.api_gateway.request.path_parameters')).to.equal(
       JSON.stringify({ param: 'some-param' })
     );
-    expect(tags.get('aws.lambda.api_gateway.request.query_string_parameters')).to.equal(
-      JSON.stringify({
-        foo: 'bar',
-        next: ['first', 'second'],
-      })
-    );
+    expect(tags.get('aws.lambda.http.query')).to.equal('foo=bar&next=first&next=second');
+
+    expect(tags.get('aws.lambda.http.status_code')).to.equal(200);
   });
 
   it('should handle API Gateway v2 HTTP API, payload v1 event', async () => {
@@ -285,16 +283,17 @@ describe('internal-extension/index.test.js', () => {
       },
     });
 
+    expect(tags.get('aws.lambda.event_source')).to.equal('aws.apigateway');
+    expect(tags.get('aws.lambda.event_type')).to.equal('aws.apigatewayv2.http.v1');
+
     expect(tags.get('aws.lambda.api_gateway.account_id')).to.equal('205994128558');
     expect(tags.get('aws.lambda.api_gateway.api_id')).to.equal('xxx');
     expect(tags.get('aws.lambda.api_gateway.api_stage')).to.equal('$default');
 
     expect(tags.get('aws.lambda.api_gateway.request.id')).to.equal('XyGqvi5mIAMEJtw=');
     expect(tags.get('aws.lambda.api_gateway.request.time_epoch')).to.equal(1662040030156);
-    expect(tags.get('aws.lambda.api_gateway.request.protocol')).to.equal('HTTP/1.1');
-    expect(tags.get('aws.lambda.api_gateway.request.domain')).to.equal(
-      'xxx.execute-api.us-east-1.amazonaws.com'
-    );
+    expect(tags.get('aws.lambda.http.protocol')).to.equal('HTTP/1.1');
+    expect(tags.get('aws.lambda.http.host')).to.equal('xxx.execute-api.us-east-1.amazonaws.com');
     expect(tags.get('aws.lambda.api_gateway.request.headers')).to.equal(
       JSON.stringify({
         'Content-Length': '385',
@@ -303,14 +302,11 @@ describe('internal-extension/index.test.js', () => {
         'Multi': ['one,stillone', 'two'],
       })
     );
-    expect(tags.get('aws.lambda.api_gateway.request.method')).to.equal('POST');
-    expect(tags.get('aws.lambda.api_gateway.request.path')).to.equal('/v1');
-    expect(tags.get('aws.lambda.api_gateway.request.query_string_parameters')).to.equal(
-      JSON.stringify({
-        lone: 'value',
-        multi: ['one,stillone', 'two'],
-      })
-    );
+    expect(tags.get('aws.lambda.http.method')).to.equal('POST');
+    expect(tags.get('aws.lambda.http.path')).to.equal('/v1');
+    expect(tags.get('aws.lambda.http.query')).to.equal('lone=value&multi=one%2Cstillone&multi=two');
+
+    expect(tags.get('aws.lambda.http.status_code')).to.equal(200);
   });
 
   it('should handle API Gateway v2 HTTP API, payload v2 event', async () => {
@@ -358,16 +354,17 @@ describe('internal-extension/index.test.js', () => {
       },
     });
 
+    expect(tags.get('aws.lambda.event_source')).to.equal('aws.apigateway');
+    expect(tags.get('aws.lambda.event_type')).to.equal('aws.apigatewayv2.http.v2');
+
     expect(tags.get('aws.lambda.api_gateway.account_id')).to.equal('205994128558');
     expect(tags.get('aws.lambda.api_gateway.api_id')).to.equal('xxx');
     expect(tags.get('aws.lambda.api_gateway.api_stage')).to.equal('$default');
 
     expect(tags.get('aws.lambda.api_gateway.request.id')).to.equal('XyGnwhe0oAMEJJw=');
     expect(tags.get('aws.lambda.api_gateway.request.time_epoch')).to.equal(1662040011065);
-    expect(tags.get('aws.lambda.api_gateway.request.protocol')).to.equal('HTTP/1.1');
-    expect(tags.get('aws.lambda.api_gateway.request.domain')).to.equal(
-      'xxx.execute-api.us-east-1.amazonaws.com'
-    );
+    expect(tags.get('aws.lambda.http.protocol')).to.equal('HTTP/1.1');
+    expect(tags.get('aws.lambda.http.host')).to.equal('xxx.execute-api.us-east-1.amazonaws.com');
     expect(tags.get('aws.lambda.api_gateway.request.headers')).to.equal(
       JSON.stringify({
         'content-length': '385',
@@ -376,14 +373,11 @@ describe('internal-extension/index.test.js', () => {
         'multi': 'one,stillone,two',
       })
     );
-    expect(tags.get('aws.lambda.api_gateway.request.method')).to.equal('POST');
-    expect(tags.get('aws.lambda.api_gateway.request.path')).to.equal('/v2');
-    expect(tags.get('aws.lambda.api_gateway.request.query_string_parameters')).to.equal(
-      JSON.stringify({
-        lone: 'value',
-        multi: 'one,stillone,two',
-      })
-    );
+    expect(tags.get('aws.lambda.http.method')).to.equal('POST');
+    expect(tags.get('aws.lambda.http.path')).to.equal('/v2');
+    expect(tags.get('aws.lambda.http.query')).to.equal('lone=value&multi=one%2Cstillone%2Ctwo');
+
+    expect(tags.get('aws.lambda.http.status_code')).to.equal(200);
   });
 
   it('should handle SQS event', async () => {
@@ -438,6 +432,9 @@ describe('internal-extension/index.test.js', () => {
       },
     });
 
+    expect(tags.get('aws.lambda.event_source')).to.equal('aws.sqs');
+    expect(tags.get('aws.lambda.event_type')).to.equal('aws.sqs');
+
     expect(tags.get('aws.lambda.sqs.queue_name')).to.equal('test.fifo');
     expect(tags.get('aws.lambda.sqs.message_ids')).to.deep.equal([
       '6f606577-4d1f-455c-b504-807abed7ca02',
@@ -501,6 +498,9 @@ describe('internal-extension/index.test.js', () => {
       },
     });
 
+    expect(tags.get('aws.lambda.event_source')).to.equal('aws.sns');
+    expect(tags.get('aws.lambda.event_type')).to.equal('aws.sns');
+
     expect(tags.get('aws.lambda.sns.topic_name')).to.equal('test');
     expect(tags.get('aws.lambda.sns.message_ids')).to.deep.equal([
       '135f0427-2c82-5850-930b-5fb608141554',