RFC: Canonical Wide Log utility for emitting a single log entry per lambda execution or processed transaction (batch) #5915
Replies: 2 comments
-
Hi, @walmsles! Thank you for opening this RFC and bringing to the table an updated concept of canonical logs. Over the last few months, I've seen this topic (and WIDE logs) being raised again in many forums and seeing how it is specializing observability into a telemetry and transaction path, which differentiates it from current logs for observability in general. This is the first interaction in this RFC, so I have some questions/thoughts to share with you to see if it makes sense. 1 - If I got it correctly, the idea of this RFC is to create a middleware to add the ability to create WIDE logs per transaction/lambda execution. Could you confirm if the idea here is to add support for WIDE logs, canonical format logs, or both? 2 - You mention creating a middleware to not only provide WIDE logging per handler execution but also propagate this logger instance across batch/idempotence/event handler executions. I have some difficulty seeing how we can share this instance between all the utilities, perhaps using a decorator on all the functions you want to use this WIDE logger instance? 3 - What is the log level of this WIDE log? 4 - We have some parameters at the 5 - When will we flush the WIDE log to output? Right after the Lambda execution has completely finished? And if the customer is processing Idempotency and Batch Processing in the same Lambda execution, wouldn't this cause some confusion between the data the customer wants in the WIDE logs? For now, these are my ideas in this RFC. I'm very excited to see that the community asks us to add new features that will help others. Thanks as always for all your help @walmsles! ❤️ |
Beta Was this translation helpful? Give feedback.
-
Conceptually Canonical and Wide logs are similar in the way they are written once to your log output, I would say they are actually the same thing. names are important which is why I personally like “Wide Logs”, it says what it is. Nobody understands what a Canonical log should be IMO 🙃. Let’s Agree - they are the same thing, and have the same logical functionality. From a Powertools perspective we should choose the name that we stay with and most customers understand.
When I think about using this kind of logging - I am generally looking to write a single log entry per transaction that gets processed. This is the complexity I was raising - to provide the utility such that it is useable in all of the following contexts:
I have a typescript implementation and I output it as “INFO” with a “WIDE” tag for filtering. I have been thinking more about whether it should be a different log level altogether in case INFO is not turned on - I feel WIDE or Canonical logs are ones you always want to write out so may need to think more about this from a level perspective - are they logs at all?, and what does that mean from an AWS Lambda perspective.
My thought here is that the Wide (or Canonical) log functionality should operate from a seperate attribute “bucket” to gather wide log data during processing. This is how my typescript implementation works, I liken it to the Metrics functionality which enables gathering of data and writes it out once.
Let’s tackle this one in pieces - there are more than one question, I will focus on the why’s and what I would like - not the HOW - this needs to come later after we agree on the contexts and function. When will we flush the WIDE log output? If the customer is processing in batch? If the customer is using Idempotency Utility? At the end of the day we should provide a utility to enable customers to use it as they need to and desire regardless of the context of operation. The functionality should be consistent and simple in each use-case so customer’s can choose how to use it. |
Beta Was this translation helpful? Give feedback.
-
Is this related to an existing feature request or issue?
No response
Which Powertools for AWS Lambda (Python) utility does this relate to?
Logger
Summary
The logger is great and offers a heap of functionality. It is very useful for developer logging, debug, info, error logging but I don't think its great for observability logging. Some ideas have been circulating in the observability community around canonical logging and, more recently, about wide events. The idea of a single log entry per Lambda function invocation holding ALL the meta-data for what occurred during that execution is a very useful concept and something I have used for tracking, tracing and observing transactions across a distributed system.
Use case
I want to be able to gather meta-data during transaction processing and store it somewhere so I can write it all out in a single place, representing everything that happened to the transaction as it was being processed by my code. I want to be able to add to this meta-data from shared-libraries and want to enable developers to easily throw meta-data into the bucket for collection when transaction processing is done.
Log attributes does this sto a degree already - but is focused on applying the meta-data to every log output, not just a single oneat the end of processing.
Proposal
Existing capability:
Using a Wide Logging utility:
Using middleware to emit the wide log means it is a set and forget operation, which adds value for developers who are already overloaded.
Being able to add in meta-data as transaction processing happens, encourages thoughtful use of meta-data attributes.
Collating them in a central object for emitting at the end means the meta-data you are collecting for observability purposes is separate from attributes you collate for debug logging - 2 very distinct purposes and separating the concerns will encourage clearer thinking on Observability vs debug.
Out of scope
Nothing.
Potential challenges
Wide logging needs to be considered at a transaction level - so not always as a per-function execution statement which is not true in the case of functions which process data through a batch mechanism - SQS, SNS, stream (DynamoDB, Kafka, Kinesis, etc). The middleware would need to apply to both batch functions and lambda handlers.
Dependencies and Integrations
This should be a natural extension of the logger utility - a slightly different function to just logging. I liken the idea of this more like the Metrics implementation where meta-data is collated during code execution and output at a singular level.This
Alternative solutions
No response
Acknowledgment
Beta Was this translation helpful? Give feedback.
All reactions