chore: add support for multiple dimensions #884
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:
AddDimensions
method 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:
SetService
method for setting the service name and a staticAddDimensions
method for adding dimensions globally (libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs
). [1] [2]AddDimensionSet
method 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]Updates to Tests:
AddDimensions
, verifying behaviors such as overwriting existing dimensions, handling empty or invalid inputs, and including default dimensions (libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/EMFValidationTests.cs
).libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/EMFValidationTests.cs
).Refactoring and Bug Fixes:
ExpandAllDimensionSets
method to ensure the last value for duplicate keys is used, aligning with expected behavior (libraries/src/AWS.Lambda.Powertools.Metrics/Model/MetricDirective.cs
).Dimensions
list (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
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.