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

chore: Powertools Logger v2 #832

Merged

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Apr 7, 2025

Please provide the issue number

Issue number: #229 | #230 | #374 | #425 | #417 | #496 | #497 | #783

Summary

Changes

In this pull request we are moving Logger to v2 and added the following features:

  • ILogger support: Support for Microsoft.Extensions.Logging, this allows for more flexibility and testability
  • Log Buffering: support for buffering Logs
  • Message templating for objects and strings
  • Fix Top Level Statement lambdas to for the correct LogLevel in CloudWatch
  • Fix coldstart metric on provisioned concurrency lambdas
  • Prevent duplicate keys or override Powertools keys in the logger
  • Option to prevent Logger to change the case of nested objects
  • Improved testability
  • Documentation updates

Project Configuration:

  • Added a new project AOT-Function-ILogger to the solution file (AWS.Lambda.Powertools.sln). This includes adding the project reference and updating the build configurations. [1] [2] [3]
  • Removed the condition on the ProjectReference in AWS.Lambda.Powertools.BatchProcessing.csproj so that it always includes AWS.Lambda.Powertools.Common.csproj.

Environment Handling:

  • Added a new constant AWSInitializationTypeEnv in Constants.cs for handling AWS Lambda initialization type.
  • Enhanced IConsoleWrapper by removing the ReadLine method.
  • Added new properties to IPowertoolsConfigurations to track cold start and AWS initialization type.
  • Added a method to IPowertoolsEnvironment to set the AWS execution environment.
  • Introduced LambdaLifecycleTracker to track Lambda lifecycle state including cold starts.
  • Updated PowertoolsConfigurations to use PowertoolsEnvironment for environment variable handling and added support for cold start and initialization type. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Enhanced PowertoolsEnvironment to set the AWS execution environment and parse assembly names. [1] [2]

User experience

Please share what the user experience looks like before and after this change

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

hjgraca added 30 commits March 6, 2025 18:58
…te logging methods. revert systemwrapper, revert lambda.core to 2.5.0
…te logging methods. revert systemwrapper, revert lambda.core to 2.5.0
hjgraca added 4 commits April 4, 2025 11:32
…ations. ColdStart logic for provisioned-concurrency
Bump logging package to 2.0.0-preview.1. Update documentation for v2.
Add integration tests.
@boring-cyborg boring-cyborg bot added area/common Core Powertools utility area/idempotency area/logging Core logging utility documentation Improvements or additions to documentation labels Apr 7, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Apr 7, 2025
@hjgraca hjgraca requested a review from leandrodamascena April 7, 2025 11:35
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 75.66313% with 367 lines in your changes missing coverage. Please review.

Project coverage is 75.73%. Comparing base (8b6d925) to head (399ba36).
Report is 58 commits behind head on develop.

Files with missing lines Patch % Lines
...S.Lambda.Powertools.Logging/Logger.StandardLogs.cs 14.28% 72 Missing ⚠️
....Lambda.Powertools.Logging/Logger.ExtraKeysLogs.cs 17.85% 69 Missing ⚠️
...c/AWS.Lambda.Powertools.Logging/Logger.JsonLogs.cs 7.14% 39 Missing ⚠️
...da.Powertools.Logging/Internal/PowertoolsLogger.cs 86.42% 18 Missing and 12 partials ⚠️
...gging/Internal/Buffer/PowertoolsBufferingLogger.cs 74.11% 21 Missing and 1 partial ⚠️
...ambda.Powertools.Logging/Internal/LoggingAspect.cs 76.19% 16 Missing and 4 partials ⚠️
.../src/AWS.Lambda.Powertools.Logging/Logger.Scope.cs 56.25% 10 Missing and 4 partials ⚠️
...a.Powertools.Logging/PowertoolsLoggerExtensions.cs 55.55% 12 Missing ⚠️
...WS.Lambda.Powertools.Common/Core/ConsoleWrapper.cs 68.57% 9 Missing and 2 partials ⚠️
...da.Powertools.Logging/Internal/Buffer/LogBuffer.cs 77.77% 9 Missing and 1 partial ⚠️
... and 16 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #832      +/-   ##
===========================================
+ Coverage    74.32%   75.73%   +1.40%     
===========================================
  Files          211      233      +22     
  Lines         8464     9391     +927     
  Branches       918     1027     +109     
===========================================
+ Hits          6291     7112     +821     
- Misses        1880     1960      +80     
- Partials       293      319      +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hjgraca hjgraca merged commit b06fa34 into aws-powertools:develop Apr 8, 2025
9 checks passed
@hjgraca hjgraca deleted the feature/logger-ilogger-instance branch April 8, 2025 10:00
@github-actions github-actions bot added the internal Maintenance changes label Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/common Core Powertools utility area/idempotency area/logging Core logging utility documentation Improvements or additions to documentation internal Maintenance changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If extra keys has property "name", the logger name in the output is overwritten
2 participants