diff --git a/lib/serverless/aws-lambda.js b/lib/serverless/aws-lambda.js index 3d3d2843e1..8df11be080 100644 --- a/lib/serverless/aws-lambda.js +++ b/lib/serverless/aws-lambda.js @@ -249,7 +249,9 @@ class AwsLambda { _getAwsAgentAttributes(event, context) { const attributes = { 'aws.lambda.arn': context.invokedFunctionArn, - 'aws.requestId': context.awsRequestId + 'aws.requestId': context.awsRequestId, + 'cloud.resource_id': context.invokedFunctionArn, + 'cloud.platform': 'aws_lambda' } const eventSourceInfo = this._detectEventType(event) diff --git a/test/unit/serverless/aws-lambda.test.js b/test/unit/serverless/aws-lambda.test.js index 2fd3772379..bd59dd60f2 100644 --- a/test/unit/serverless/aws-lambda.test.js +++ b/test/unit/serverless/aws-lambda.test.js @@ -25,6 +25,8 @@ const LAMBDA_ARN = 'aws.lambda.arn' const COLDSTART = 'aws.lambda.coldStart' const EVENTSOURCE_ARN = 'aws.lambda.eventSource.arn' const EVENTSOURCE_TYPE = 'aws.lambda.eventSource.eventType' +const PLATFORM = 'cloud.platform' +const RESOURCE_ID = 'cloud.resource_id' function getMetrics(agent) { return agent.metrics._metrics @@ -62,7 +64,8 @@ test('AwsLambda.patchLambdaHandler', async (t) => { functionVersion: 'TestVersion', invokedFunctionArn: 'arn:test:function', memoryLimitInMB: '128', - awsRequestId: 'testid' + awsRequestId: 'testid', + platform: 'aws_lambda' } ctx.nr.stubCallback = () => {} @@ -624,7 +627,8 @@ test('AwsLambda.patchLambdaHandler', async (t) => { assert.equal(txTrace[REQ_ID], stubContext.awsRequestId) assert.equal(txTrace[LAMBDA_ARN], stubContext.invokedFunctionArn) assert.equal(txTrace[COLDSTART], true) - + assert.equal(txTrace[PLATFORM], stubContext.platform) + assert.equal(txTrace[RESOURCE_ID], stubContext.invokedFunctionArn) end() }