Skip to content

Commit d9ae35d

Browse files
committed
Set Lambda faas.invoked_region from the backfilled region in the response hook
1 parent dd642a7 commit d9ae35d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • packages/server-utils/src/integrations/tracing-channel/aws-sdk/services

packages/server-utils/src/integrations/tracing-channel/aws-sdk/services/lambda.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ export class LambdaServiceExtension implements ServiceExtension {
2525
[ATTR_FAAS_INVOKED_NAME]: functionName,
2626
[ATTR_FAAS_INVOKED_PROVIDER]: 'aws',
2727
};
28-
if (request.region) {
29-
spanAttributes[ATTR_FAAS_INVOKED_REGION] = request.region;
30-
}
3128
spanName = `${functionName} ${INVOKE_COMMAND}`;
3229
break;
3330
}
@@ -47,6 +44,11 @@ export class LambdaServiceExtension implements ServiceExtension {
4744
public responseHook(response: NormalizedResponse, span: Span): void {
4845
if (response.request.commandName === INVOKE_COMMAND) {
4946
span.setAttribute(ATTR_FAAS_EXECUTION, response.requestId);
47+
// Region resolves asynchronously after `requestPreSpanHook`, so it's backfilled onto the
48+
// normalized request and read here (same timing as `cloud.region`).
49+
if (response.request.region) {
50+
span.setAttribute(ATTR_FAAS_INVOKED_REGION, response.request.region);
51+
}
5052
}
5153
}
5254
}

0 commit comments

Comments
 (0)