Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added ARN and provider to Lambda segments #2674

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading