chore: add support for multiple dimensions#884
Merged
Conversation
2 tasks
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #884 +/- ##
===========================================
+ Coverage 77.24% 77.28% +0.03%
===========================================
Files 272 272
Lines 10812 10875 +63
Branches 1264 1278 +14
===========================================
+ Hits 8352 8405 +53
- Misses 2047 2054 +7
- Partials 413 416 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
leandrodamascena
approved these changes
Jul 8, 2025
leandrodamascena
left a comment
Contributor
There was a problem hiding this comment.
Amazing job @hjgraca!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number: #845
Summary
Changes
adding support for multiple dimensions in a single call, updating dimension validation and management logic, and introducing new unit tests to ensure robustness.
Enhancements to Dimension Handling:
AddDimensionsmethod to support adding multiple dimensions at once, with validation for non-null keys and values (libraries/src/AWS.Lambda.Powertools.Metrics/IMetrics.cs,libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs,libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricDirective.cs). [1] [2] [3]libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricDirective.cs). [1] [2]API Improvements:
SetServicemethod for setting the service name and a staticAddDimensionsmethod for adding dimensions globally (libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs). [1] [2]AddDimensionSetmethod to handle lists of dimensions, ensuring they are treated as cohesive units (libraries/src/AWS.Lambda.Powertools.Metrics/Model/Metadata.cs,libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricsContext.cs). [1] [2]Refactoring and Bug Fixes:
ExpandAllDimensionSetsmethod to ensure the last value for duplicate keys is used, aligning with expected behavior (libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricDirective.cs).Dimensionslist (libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs).These updates enhance the flexibility and reliability of the Metrics library, making it easier to manage and validate dimensions in AWS Lambda applications.
User experience
Output
{ "_aws": { "Timestamp": 1747649334042, "CloudWatchMetrics": [ { "Namespace": "dotnet-powertools-test", "Metrics": [ { "Name": "TestMetric", "Unit": "Count" } ], "Dimensions": [ [ "Service", "Environment", "Region" ] ] } ] }, "Service": "testService", "Environment": "test", "Region": "us-west-2", "TestMetric": 1 }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.