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

feat(logging): Extract and store arbitrary values from the request #817

Open
wants to merge 71 commits into
base: develop
Choose a base branch
from

Conversation

gregsinclair42
Copy link
Contributor

@gregsinclair42 gregsinclair42 commented Mar 12, 2025

Please provide the issue number

Issue number: #816

Summary

Can now easily extract arbitrary values from the request and store as a logging key.

Changes

Please provide a summary of what's being changed

  • Added a new parameter to LoggingAttribute called ExtractedKeyPaths
  • Added a general private function CaptureKeyFromPath that works the same as CaptureCorrelationId did, but now it works for arbitrary keys and paths
  • Updated a unit test

User experience

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

Before: You would have to write custom code that executes on every request to extract the fields from the header for example, and save it in the log key. This is less convenient than adding it to the existing Logging attribute.

After: Simply update the parameter in the Logging attribute and it will do this work for you:

[Logging(ExtractedKeyPaths = [("Header/Device-Id", "DeviceId"), ("Header/User-Id", "UserId")]
void MyHandler(APIGatewayProxyRequest request, ILambdaContext context)
{
///
}

Checklist

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

Is this a breaking change? NO

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.

sliedig and others added 30 commits January 31, 2023 16:24
chore(ci): Adding additional maintenace fixes to main
chore(ci): merge develop to main for NuGet references for examples update
chore: Sync main with develop for release 1.4.1
chore: Sync main with develop for release 1.4.2
chore: Sync develop to main for release
chore: Sync develop to main post release
chore: Sync main with develop for release 1.8.1
chore: Sync main - develop - Update examples
hjgraca and others added 19 commits August 27, 2024 10:45
chore: Sync Main with Develop release 1.13
chore: Sync main with develop for release 1.13
chore: sync main with dev for release 1.13
chore: Sync main and develop for release 1.13
chore: Sync main with develop for release 1.14
chore: Sync main with develop for relase 1.14
chore: Sync main with develop for release
chore: Sync main with Master for Tracing fix
chore: Sync main with develop for release to fix metrics output
chore: Sync main with develop for release 1.16
chore: Sync main with develop for release 1.17
chore: Sync main with develop for release 1.18
chore: Sync main with develop for release 1.18
chore: Sync main with develop for release 1.19
chore: sync main with develop for release 1.19
chore: Sync main with develop for release 1.20
@boring-cyborg boring-cyborg bot added area/logging Core logging utility tests labels Mar 12, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 12, 2025
@gregsinclair42 gregsinclair42 marked this pull request as ready for review March 12, 2025 20:38
@gregsinclair42 gregsinclair42 changed the title feat(logging): Extract and store arbitrary values from the request) feat(logging): Extract and store arbitrary values from the request Mar 12, 2025
@github-actions github-actions bot added the feature New features or minor changes label Mar 13, 2025
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.12%. Comparing base (1a8c29c) to head (c5e62fa).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
...ambda.Powertools.Logging/Internal/LoggingAspect.cs 95.83% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #817      +/-   ##
===========================================
- Coverage    74.15%   74.12%   -0.03%     
===========================================
  Files          210      210              
  Lines         8411     8425      +14     
  Branches       909      911       +2     
===========================================
+ Hits          6237     6245       +8     
- Misses        1881     1886       +5     
- Partials       293      294       +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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging Core logging utility feature New features or minor changes size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add ability to extract arbitrary fields from the request and store in log keys
4 participants