Skip to content

Conversation

@hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Dec 12, 2025

Please provide the issue number

Issue number: #1076 #1077

Summary

Changes

This pull request introduces significant improvements to concurrency handling in the Powertools Logger, ensuring thread- and invocation-safe logging in AWS Lambda environments with concurrent execution (LMI). It achieves this by refactoring scope storage to be thread-local, adding comprehensive concurrency tests, and updating dependencies for better compatibility. The most important changes are grouped below.

Concurrency and Thread Safety Improvements:

  • Refactored the Logger's scope storage to use a thread-safe ConcurrentDictionary keyed by Environment.CurrentManagedThreadId, isolating log scopes per thread and preventing cross-invocation contamination in concurrent Lambda executions (Logger.Scope.cs). [1] [2]
  • Updated the RemoveAllKeys method to clear only the current thread's scope, further ensuring isolation between concurrent invocations (Logger.Scope.cs).

Dependency and Solution Updates:

  • Upgraded Amazon.Lambda.Core and related dependencies to version 2.8.0 across source and test projects for improved Lambda compatibility and feature support (Directory.Packages.props, AWS.Lambda.Powertools.Parameters.csproj, AWS.Lambda.Powertools.Tracing.csproj, test props). [1] [2] [3] [4]
  • Added the new concurrency test project to the solution file and ensured proper build configuration and nesting (AWS.Lambda.Powertools.sln). [1] [2] [3]

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.

…orage.

Add new TraceId capture from Lambda.Core to PowertoolsConfigurations.cs
add new concurrency tests
@boring-cyborg boring-cyborg bot added area/common Core Powertools utility area/logging Core logging utility area/parameters area/tracing Core tracing utility tests labels Dec 12, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Dec 12, 2025
@github-actions github-actions bot added the feature New features or minor changes label Dec 12, 2025
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.24%. Comparing base (eff1550) to head (de9ceba).
⚠️ Report is 22 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1078      +/-   ##
===========================================
+ Coverage    78.18%   78.24%   +0.06%     
===========================================
  Files          298      298              
  Lines        12037    12045       +8     
  Branches      1449     1450       +1     
===========================================
+ Hits          9411     9425      +14     
+ Misses        2161     2156       -5     
+ Partials       465      464       -1     

☔ 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 1d9594e into develop Dec 16, 2025
9 checks passed
@hjgraca hjgraca deleted the feat/logger-thread-safety branch December 16, 2025 10:08
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/logging Core logging utility area/parameters area/tracing Core tracing utility feature New features or minor changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants