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
perf(logger): defer execution of expensive logging calls #614
Merged
Conversation
This file contains 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
brettstack
approved these changes
May 7, 2023
Thanks for this! Those are some impressive numbers. Surprising how much that inspect can tax it. |
github-actions bot
pushed a commit
that referenced
this pull request
May 7, 2023
## [4.10.2](v4.10.1...v4.10.2) (2023-05-07) ### Performance Improvements * **logger:** defer execution of expensive logging calls ([#614](#614)) ([7d42c6d](7d42c6d))
🎉 This PR is included in version 4.10.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
vanbasten17
added a commit
to hubtype/botonic
that referenced
this pull request
Jun 27, 2023
<p>This PR was automatically created by Snyk using the credentials of a real user.</p><br /><h3>Snyk has created this PR to upgrade @vendia/serverless-express from 4.10.1 to 4.10.4.</h3> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. <hr/> - The recommended version is **3 versions** ahead of your current version. - The recommended version was released **a month ago**, on 2023-05-21. <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>@vendia/serverless-express</b></summary> <ul> <li> <b>4.10.4</b> - <a href="https://snyk.io/redirect/github/vendia/serverless-express/releases/tag/v4.10.4">2023-05-21</a></br><h2><a href="https://snyk.io/redirect/github/vendia/serverless-express/compare/v4.10.3...v4.10.4">4.10.4</a> (2023-05-21)</h2> <h3>Bug Fixes</h3> <ul> <li>logging (<a href="https://snyk.io/redirect/github/vendia/serverless-express/issues/652" data-hovercard-type="pull_request" data-hovercard-url="/CodeGenieApp/serverless-express/pull/652/hovercard">#652</a>) (<a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/dfcb71a59b29f1249cd1f8f58476620ef0f276a4">dfcb71a</a>), closes <a href="https://snyk.io/redirect/github/vendia/serverless-express/issues/651" data-hovercard-type="issue" data-hovercard-url="/CodeGenieApp/serverless-express/issues/651/hovercard">#651</a></li> </ul> </li> <li> <b>4.10.3</b> - <a href="https://snyk.io/redirect/github/vendia/serverless-express/releases/tag/v4.10.3">2023-05-08</a></br><h2><a href="https://snyk.io/redirect/github/vendia/serverless-express/compare/v4.10.2...v4.10.3">4.10.3</a> (2023-05-08)</h2> <h3>Bug Fixes</h3> <ul> <li>upgrade json5 dependency (<a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/f20ec470c1d436a955972c172a752fa62614e286">f20ec47</a>)</li> </ul> </li> <li> <b>4.10.2</b> - <a href="https://snyk.io/redirect/github/vendia/serverless-express/releases/tag/v4.10.2">2023-05-07</a></br><h2><a href="https://snyk.io/redirect/github/vendia/serverless-express/compare/v4.10.1...v4.10.2">4.10.2</a> (2023-05-07)</h2> <h3>Performance Improvements</h3> <ul> <li><strong>logger:</strong> defer execution of expensive logging calls (<a href="https://snyk.io/redirect/github/vendia/serverless-express/issues/614" data-hovercard-type="pull_request" data-hovercard-url="/CodeGenieApp/serverless-express/pull/614/hovercard">#614</a>) (<a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/7d42c6d55cb9c27d6ace81f62b3f90d882480d35">7d42c6d</a>)</li> </ul> </li> <li> <b>4.10.1</b> - <a href="https://snyk.io/redirect/github/vendia/serverless-express/releases/tag/v4.10.1">2022-07-26</a></br><h2><a href="https://snyk.io/redirect/github/vendia/serverless-express/compare/v4.10.0...v4.10.1">4.10.1</a> (2022-07-26)</h2> <h3>Bug Fixes</h3> <ul> <li><strong>http-function-runtime-v3:</strong> fix undeclared variable and added improve tests for set-cookie (<a href="https://snyk.io/redirect/github/vendia/serverless-express/issues/534" data-hovercard-type="pull_request" data-hovercard-url="/CodeGenieApp/serverless-express/pull/534/hovercard">#534</a>) (<a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/34bd7da3fa20d754a98a59324a2bf7dc1e73a30c">34bd7da</a>)</li> </ul> </li> </ul> from <a href="https://snyk.io/redirect/github/vendia/serverless-express/releases">@vendia/serverless-express GitHub release notes</a> </details> </details> <details> <summary><b>Commit messages</b></summary> </br> <details> <summary>Package name: <b>@vendia/serverless-express</b></summary> <ul> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/75e9de327972ad372a89cd7ae586b53c73c048f0">75e9de3</a> chore(release): 4.10.4 [skip ci]</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/dfcb71a59b29f1249cd1f8f58476620ef0f276a4">dfcb71a</a> fix: logging (#652)</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/d5246a7885561eb055ad74c22b0368cc2d54efe7">d5246a7</a> chore(release): 4.10.3 [skip ci]</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/f20ec470c1d436a955972c172a752fa62614e286">f20ec47</a> fix: upgrade json5 dependency</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/acdcbd65d04edbce14f9c9c917191538b9138cc7">acdcbd6</a> chore: revert update dependencies</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/41f6dc8573b41a52476823c00a780dc4fc36195f">41f6dc8</a> chore: update dependencies</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/79d030c45e3fb32226fd2be7daf2460f8344723f">79d030c</a> docs: remove contributor covenant badge</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/dbc64fa44045b66fe669282a9a4fdcbbe6d003b1">dbc64fa</a> docs: update readme</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/649eca084ebbbb1710cfd6e6141e728182bea2c8">649eca0</a> docs: update Vendia logo</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/89f2b4faa507a98c47da58dc64686c3dbcb7f924">89f2b4f</a> chore: export ConfigureResult interface (#584)</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/d45fdd2fda8c347b54e75f6c19ed48e258e5f88e">d45fdd2</a> chore(release): 4.10.2 [skip ci]</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/7d42c6d55cb9c27d6ace81f62b3f90d882480d35">7d42c6d</a> perf(logger): defer execution of expensive logging calls (#614)</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/0909ec4ffd09d9fd22538257b721b7d076d03732">0909ec4</a> ci: add nodejs18.x to test matrix; update examples to use 18.x</li> <li><a href="https://snyk.io/redirect/github/vendia/serverless-express/commit/75cfbffeb3fd030695b9587a75300c7b8012ac6a">75cfbff</a> chore(deps): Bump moment-timezone in /examples/basic-starter-nestjs (#550)</li> </ul> <a href="https://snyk.io/redirect/github/vendia/serverless-express/compare/19874846dec30ad1101ed73f794c3a8a74c85700...75e9de327972ad372a89cd7ae586b53c73c048f0">Compare</a> </details> </details> <hr/> **Note:** *You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.* For more information: <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI2ZWZiM2NmZi1jZmMwLTQxNzktYWYwZi0yZWQ5Y2M2Nzc2NDkiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjZlZmIzY2ZmLWNmYzAtNDE3OS1hZjBmLTJlZDljYzY3NzY0OSJ9fQ==" width="0" height="0"/> 🧐 [View latest project report](https://app.snyk.io/org/manuelfidalgo/project/1e476a2c-f968-4574-8a48-a93a0982eecc?utm_source=github&utm_medium=referral&page=upgrade-pr) 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/manuelfidalgo/project/1e476a2c-f968-4574-8a48-a93a0982eecc/settings/integration?utm_source=github&utm_medium=referral&page=upgrade-pr) 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/manuelfidalgo/project/1e476a2c-f968-4574-8a48-a93a0982eecc/settings/integration?pkg=@vendia/serverless-express&utm_source=github&utm_medium=referral&page=upgrade-pr#auto-dep-upgrades) <!--- (snyk:metadata:{"prId":"6efb3cff-cfc0-4179-af0f-2ed9cc677649","prPublicId":"6efb3cff-cfc0-4179-af0f-2ed9cc677649","dependencies":[{"name":"@vendia/serverless-express","from":"4.10.1","to":"4.10.4"}],"packageManager":"npm","type":"auto","projectUrl":"https://app.snyk.io/org/manuelfidalgo/project/1e476a2c-f968-4574-8a48-a93a0982eecc?utm_source=github&utm_medium=referral&page=upgrade-pr","projectPublicId":"1e476a2c-f968-4574-8a48-a93a0982eecc","env":"prod","prType":"upgrade","vulns":[],"issuesToFix":[],"upgrade":[],"upgradeInfo":{"versionsDiff":3,"publishedDate":"2023-05-21T22:25:47.789Z"},"templateVariants":[],"hasFixes":false,"isMajorUpgrade":false,"isBreakingChange":false,"priorityScoreList":[]}) ---> Co-authored-by: snyk-bot <snyk-bot@snyk.io> Co-authored-by: van Basten 17 <35448568+vanbasten17@users.noreply.github.com>
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.
Fixes #613
Description of changes:
The calls of
util.inspect
is very expensive to run, so I defer the execution of the logging by passing a function, inside the logger, I check if is a function then I execute it to get the value.This could introduce a breaking change if someone overrides the logging library, so the logs that are functions will not be evaluated correctly, but this is the logging of the internal library so I don't know if configures a breaking change.
Another approach to fix the issue is using the variable
logSettings.level
and guarding the log calls by checking if thelevel
is equal todebug
. But this approach makes us pass thelogSettings
to all functions that uselog
, so I don't know either if is a good fixing.Let me know what you think about the current solution, if don't worth the little breaking change, I can try to modify to use guards with
logSettings
.To summarize the improvements, below we have the number of op/s in the old version:
Now, this is the number of op/s:
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.