Conversation
- Add ExtraKeys() method to Logger for temporary key management within scopes - Implement AsyncLocal-based scope storage to support async/await boundaries - Replace thread-based scope isolation with async execution context isolation - Add LoggerScopeContext disposable for automatic key cleanup on scope exit - Support multiple overloads: Dictionary, params tuples, and nested scopes - Add comprehensive documentation with examples for Dictionary, Tuples, and nested usage - Add AsyncSafetyTests to verify keys flow correctly across async operations - Add ExtraKeysTests to validate temporary key isolation and cleanup - Update KeyIsolationTests for new async-based scope implementation - Provide guidance on ExtraKeys vs AppendKey usage patterns
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1128 +/- ##
========================================
Coverage 79.23% 79.24%
========================================
Files 299 299
Lines 12441 12495 +54
Branches 1490 1495 +5
========================================
+ Hits 9858 9902 +44
- Misses 2128 2137 +9
- Partials 455 456 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This pull request implements the ExtraKeys feature for the Logger, addressing issue #1037. The feature provides a convenient scoped way to add temporary logging keys that are automatically removed when the scope is disposed.
Changes:
- Migrated from thread-based scope isolation to AsyncLocal-based execution context isolation for better async/await support
- Added ExtraKeys methods with Dictionary and tuple overloads for temporary key management
- Added comprehensive test coverage including async safety tests and extra keys tests
- Updated documentation with examples and usage guidance
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/src/AWS.Lambda.Powertools.Logging/Logger.Scope.cs | Implements AsyncLocal-based scope storage, ExtraKeys methods, and LoggerExtraKeysScope disposable |
| libraries/src/AWS.Lambda.Powertools.Logging/PowertoolsLoggerExtensions.cs | Adds ExtraKeys extension methods for ILogger |
| libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/ExtraKeysTests.cs | Comprehensive tests for ExtraKeys functionality |
| libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/AsyncSafetyTests.cs | Tests validating async/await safety of logger keys |
| libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/KeyIsolationTests.cs | Updated to use Logger.UseScope() for simulating Lambda multi-threaded mode |
| docs/core/logging.md | Added documentation for ExtraKeys with examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/AsyncSafetyTests.cs
Show resolved
Hide resolved
libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/AsyncSafetyTests.cs
Show resolved
Hide resolved
libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/AsyncSafetyTests.cs
Show resolved
Hide resolved
libraries/tests/AWS.Lambda.Powertools.ConcurrencyTests/Logging/ExtraKeysTests.cs
Show resolved
Hide resolved
|



Issue number: #1037
Summary
Changes
User experience
Checklist
Please leave checklist items unchecked if they do not apply to your change.
Is this a breaking change?
RFC issue number:
Checklist:
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.