Skip to content

Conversation

@hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Oct 23, 2025

Please provide the issue number

Issue number: closes #1048

Summary

Changes

This pull request introduces improved support for retrieving correlation IDs.
The changes focus on making the correlation ID extraction more robust, exposing it via new APIs

Correlation ID extraction improvements

  • Enhanced the CaptureCorrelationId method in LoggingAspect.cs to try multiple strategies for extracting the correlation ID: first by exact (case-sensitive) match, then by output case transformation, and finally by case-insensitive search. This makes correlation ID retrieval more reliable across various event shapes.

Public API enhancements

  • Added a static CorrelationId property to the Logger class, allowing easy access to the current correlation ID from log context.
  • Introduced a new GetCorrelationId extension method for ILogger, providing a convenient way to access the correlation ID from any logger instance.

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.

…ies in order:

Original path (case-sensitive) - tries the exact path you specified
Output case transformation - applies the configured logger output case (for backward compatibility)
Case-insensitive match - falls back to case-insensitive property matching
@boring-cyborg boring-cyborg bot added area/logging Core logging utility tests labels Oct 23, 2025
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 23, 2025
@github-actions github-actions bot added the internal Maintenance changes label Oct 23, 2025
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.20%. Comparing base (12573e5) to head (8bcea71).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
...ambda.Powertools.Logging/Internal/LoggingAspect.cs 94.73% 1 Missing ⚠️
.../src/AWS.Lambda.Powertools.Logging/Logger.Scope.cs 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1049      +/-   ##
===========================================
+ Coverage    78.17%   78.20%   +0.02%     
===========================================
  Files          298      298              
  Lines        12012    12037      +25     
  Branches      1443     1449       +6     
===========================================
+ Hits          9390     9413      +23     
  Misses        2160     2160              
- Partials       462      464       +2     

☔ 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.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/logging Core logging utility internal Maintenance changes size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Correlation ID extraction fails for CloudWatch Events with custom paths

1 participant