-
Notifications
You must be signed in to change notification settings - Fork 154
docs: Add usage sub-section in docs #604
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 tasks
saragerion
previously approved these changes
Mar 1, 2022
ijemmy
reviewed
Mar 3, 2022
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 change the wording a bit to make it more accurate and concise. What do you think?
docs/core/logger.md
Outdated
@@ -29,6 +29,22 @@ Install the library in your project: | |||
npm install @aws-lambda-powertools/logger | |||
``` | |||
|
|||
### Usage | |||
|
|||
The `Logger` utility should always be instantiated outside of the Lambda handler. In doing this, subsequent invocations processed by the same instance of your function can reuse these resources. This saves cost by reducing function run time. In addition to this, `Logger` can also be aware of things like whether or not a given invocation had a cold start or not and inject the appropriate fields into the log. |
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.
Suggested change
The `Logger` utility should always be instantiated outside of the Lambda handler. In doing this, subsequent invocations processed by the same instance of your function can reuse these resources. This saves cost by reducing function run time. In addition to this, `Logger` can also be aware of things like whether or not a given invocation had a cold start or not and inject the appropriate fields into the log. | |
The `Logger` utility must always be instantiated outside of the Lambda handler. In doing this, subsequent invocations processed by the same instance of your function can reuse these resources. This saves cost by reducing function run time. In addition, `Logger` can track cold start and inject the appropriate fields into the logs. |
Co-authored-by: ijemmy <[email protected]>
Co-authored-by: ijemmy <[email protected]>
Co-authored-by: ijemmy <[email protected]>
ijemmy
approved these changes
Mar 3, 2022
saragerion
approved these changes
Mar 3, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of your changes
Following the changes introduced in #550 and this comment from @saragerion, this PR introduces a new short "Usage" sub-section under the "Getting Started" section of each utility's page.
The goal of this section is to give a very basic example of the library's usage (just import & initialisation outside of handler) and point out why the utility has to be instantiated outside of the handler, explaining also benefits of doing so.
This wording was initially under the SAM section because that was the first code snippet but given that this disclaimer is not SAM-specific it deserves its own section.
How to verify this change
Tracer
Logger
Metrics
Related issues, RFCs
#550
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
N/A
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.