Skip to content
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

docs: Add usage sub-section in docs #604

Merged
merged 4 commits into from
Mar 3, 2022
Merged

Conversation

dreamorosi
Copy link
Contributor

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

Screenshot 2022-02-28 at 16 06 05

Logger

image

Metrics

image

Related issues, RFCs

#550

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • New and existing unit tests pass locally and in Github Actions
  • The PR title follows the conventional commit semantics

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.

@dreamorosi dreamorosi added documentation Improvements or additions to documentation enhancement labels Feb 28, 2022
@dreamorosi dreamorosi added this to the production-ready-release milestone Feb 28, 2022
@dreamorosi dreamorosi self-assigned this Feb 28, 2022
saragerion
saragerion previously approved these changes Mar 1, 2022
Copy link
Contributor

@ijemmy ijemmy left a 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 Show resolved Hide resolved
docs/core/metrics.md Outdated Show resolved Hide resolved
@@ -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.
Copy link
Contributor

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.

docs/core/tracer.md Outdated Show resolved Hide resolved
Co-authored-by: ijemmy <ijemmy@users.noreply.github.com>
dreamorosi and others added 2 commits March 3, 2022 15:54
Co-authored-by: ijemmy <ijemmy@users.noreply.github.com>
Co-authored-by: ijemmy <ijemmy@users.noreply.github.com>
@dreamorosi dreamorosi merged commit 63a503f into main Mar 3, 2022
@dreamorosi dreamorosi deleted the docs/improve_cold_start_msgs branch March 3, 2022 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants