generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Labels
feature-requestNew feature or requestNew feature or requestgood-first-issueGood for newcomersGood for newcomerslogger
Description
Use case
With the new Lambda Tenant Isolation feature, we have access to the TenantId from the LambdaContext object.
We should add the TenantId to the default properties in the Logging utility.
https://docs.aws.amazon.com/lambda/latest/dg/tenant-isolation.html
Solution/User Experience
We need to add support for both logging backends, log4j2 and logback. The outcome should be that (without the user changing any code) the emitted JSON will contain tenant_id.
{
"level": "Information",
"message": "User object: Doe, John (42)",
"timestamp": "2025-04-07 09:06:30.708",
"service": "user-service",
"coldStart": true,
"name": "...",
"user": {
"firstName": "John",
"lastName": "Doe",
"age": 42
},
...
"tenantId": "cff02b3a-0e12-4be2-b3e0-758b49c4cd9b"
...
}Implementation suggestion
For Log4j2:
- Update JSON layouts in https://github.com/aws-powertools/powertools-lambda-java/tree/main/powertools-logging/powertools-logging-log4j/src/main/resources
- Create a new tenant id resolver in https://github.com/aws-powertools/powertools-lambda-java/blob/main/powertools-logging/powertools-logging-log4j/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/PowertoolsResolver.java
For Logback:
- Update https://github.com/aws-powertools/powertools-lambda-java/blob/main/powertools-logging/powertools-logging-logback/src/main/java/software/amazon/lambda/powertools/logging/logback/LambdaJsonEncoder.java
- Update https://github.com/aws-powertools/powertools-lambda-java/blob/main/powertools-logging/powertools-logging-logback/src/main/java/software/amazon/lambda/powertools/logging/logback/LambdaEcsEncoder.java
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Java) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, TypeScript, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
feature-requestNew feature or requestNew feature or requestgood-first-issueGood for newcomersGood for newcomerslogger
Type
Projects
Status
Backlog