Skip to content

Commit

Permalink
feat: Added ARN and provider to Lambda segments (newrelic#2674)
Browse files Browse the repository at this point in the history
Signed-off-by: mrickard <[email protected]>
  • Loading branch information
mrickard authored Oct 29, 2024
1 parent e4d0503 commit a23294c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/serverless/aws-lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions test/unit/serverless/aws-lambda.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = () => {}

Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit a23294c

Please sign in to comment.