-
Notifications
You must be signed in to change notification settings - Fork 116
fix [core] trace level shows the first kb of the payload before being decoded #534
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
Changes from 1 commit
33cec70
ab5d58e
de88eb5
96fd150
14b7922
310501f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -44,6 +44,21 @@ public enum Lambda { | |||||||||||||||||||||||||||||||||||||||
let (invocation, writer) = try await runtimeClient.nextInvocation() | ||||||||||||||||||||||||||||||||||||||||
logger[metadataKey: "aws-request-id"] = "\(invocation.metadata.requestID)" | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
// when log level is trace or lower, print the first Kb of the payload | ||||||||||||||||||||||||||||||||||||||||
let bytes = invocation.event | ||||||||||||||||||||||||||||||||||||||||
var metadata: Logger.Metadata? = nil | ||||||||||||||||||||||||||||||||||||||||
if logger.logLevel <= .trace, | ||||||||||||||||||||||||||||||||||||||||
let buffer = bytes.getSlice(at: 0, length: min(bytes.readableBytes, 1024)) | ||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||
metadata = [ | ||||||||||||||||||||||||||||||||||||||||
"Event's first bytes": .string(String(buffer: buffer) + (bytes.readableBytes > 1024 ? "..." : "")) | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The magic number 1024 appears again here. This should use the same named constant suggested for line 51 to ensure consistency and easier maintenance.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Initialize metadata as nil and then conditionally assign it can be simplified. Consider declaring it as an optional and assigning it directly within the if block, or initialize it as an empty dictionary and conditionally populate it.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
logger.trace( | ||||||||||||||||||||||||||||||||||||||||
"Sending invocation event to lambda handler", | ||||||||||||||||||||||||||||||||||||||||
metadata: metadata | ||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
do { | ||||||||||||||||||||||||||||||||||||||||
try await handler.handle( | ||||||||||||||||||||||||||||||||||||||||
invocation.event, | ||||||||||||||||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.