-
Notifications
You must be signed in to change notification settings - Fork 118
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 ? "..." : "")) | ||||||||||||||||||||||||||||||||||||||||
|
let buffer = bytes.getSlice(at: 0, length: min(bytes.readableBytes, 1024)) | |
{ | |
metadata = [ | |
"Event's first bytes": .string(String(buffer: buffer) + (bytes.readableBytes > 1024 ? "..." : "")) | |
let buffer = bytes.getSlice(at: 0, length: min(bytes.readableBytes, MAX_PREVIEW_BYTES)) | |
{ | |
metadata = [ | |
"Event's first bytes": .string(String(buffer: buffer) + (bytes.readableBytes > MAX_PREVIEW_BYTES ? "..." : "")) |
Copilot uses AI. Check for mistakes.
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.
[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.
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 ? "..." : "")) | |
] | |
if logger.logLevel <= .trace, | |
let buffer = bytes.getSlice(at: 0, length: min(bytes.readableBytes, 1024)) | |
{ | |
let metadata: Logger.Metadata = [ | |
"Event's first bytes": .string(String(buffer: buffer) + (bytes.readableBytes > 1024 ? "..." : "")) | |
] | |
logger.trace( | |
"Sending invocation event to lambda handler", | |
metadata: metadata | |
) | |
} else { | |
logger.trace("Sending invocation event to lambda handler") |
Copilot uses AI. Check for mistakes.
Uh oh!
There was an error while loading. Please reload this page.