-
Notifications
You must be signed in to change notification settings - Fork 238
Add tenant id to lambda context and structured log messages #540
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job @ramisa2108 ! 💯
I left only some small comments, let me know if that makes sense
@@ -333,6 +334,31 @@ public void nextTest() { | |||
} | |||
} | |||
|
|||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great test! 💯
@@ -581,7 +581,8 @@ public ByteArrayOutputStream call(InvocationRequest request) throws Error, Excep | |||
cognitoIdentity, | |||
LambdaEnvironment.FUNCTION_VERSION, | |||
request.getInvokedFunctionArn(), | |||
clientContext | |||
clientContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to leave the clientContext as the last parameter? This way we keep aws-related fields grouped. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestion. Updated.
@@ -34,7 +35,8 @@ public LambdaContext( | |||
CognitoIdentity identity, | |||
String functionVersion, | |||
String invokedFunctionArn, | |||
ClientContext clientContext | |||
ClientContext clientContext, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, maybe it would be better to swap args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
mockResponse.setHeader("lambda-runtime-aws-request-id", "1234567890"); | ||
mockResponse.setHeader("Content-Type", "application/json"); | ||
String expectedTenantId = "my-tenant-id"; | ||
mockResponse.setHeader("lambda-runtime-aws-tenant-id", expectedTenantId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be great to have another set of tests for:
- header not present
- header present and empty string
- header present and null value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Added these test cases.
@@ -61,6 +61,11 @@ struct invocation_request { | |||
*/ | |||
std::chrono::time_point<std::chrono::system_clock> deadline; | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hopefully at some point, we won't have a copy of aws-lambda-cpp in here, so let's keep that change here but I think you also need to modify the source of truth here: https://github.com/awslabs/aws-lambda-cpp? (Not blocking for this PR to be merged) I've also created an issue for us to track that change at some point: #541
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, one day, we could get rid of this. (Not blocking PR from my end either).
@@ -29,7 +29,8 @@ void testFormattingWithLambdaContext() { | |||
null, | |||
null, | |||
"function-arn", | |||
null | |||
null, | |||
"tenant-id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also add a test with a null value for tenant-id as it's optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added test with null tenant-id.
30c667c
to
b7c13ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! 🎉
Issue #, if available:
Description of changes:
Target (OCI, Managed Runtime, both):
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.