Repository navigation
Conversation
…cs initialization. Adding default dimensions to cold start metrics
…p and refactor initialization logic
… options and enhance default dimensions handling
…ions and improve documentation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #771 +/- ##
===========================================
+ Coverage 73.43% 73.82% +0.38%
===========================================
Files 205 205
Lines 8323 8324 +1
Branches 901 901
===========================================
+ Hits 6112 6145 +33
+ Misses 1908 1884 -24
+ Partials 303 295 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
2 tasks done
…a-dotnet into feature/metrics-default-dimensions-coldstart
…ns-coldstart' into feature/metrics-default-dimensions-coldstart
…g test for empty metrics exception
…d add corresponding tests
|
leandrodamascena
requested changes
Feb 25, 2025
leandrodamascena
left a comment
Contributor
There was a problem hiding this comment.
Hey @hjgraca! Super nice work! I just left a small comment to make the code more clear.
leandrodamascena
approved these changes
Feb 26, 2025
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: #654
Summary
Changes
This pull request includes significant changes to the
AWS.Lambda.Powertools.Metricslibrary, focusing on improving the interface and functionality of theMetricsclass and related components. The primary changes involve refactoring theIMetricsinterface, enhancing theMetricsclass, and updating theMetricsAspectclass to support the new configuration approach.Metrics.Configure
You can now configure Metrics in the constructor, this allows to configure default dimensions and other properties
Testing with dependency injection
With this new model you can finally test Metrics with dependency injection
Builder pattern
You can also create a Metrics instance with Builder pattern. As you can see in the example bellow all properties can be set in the constructor and will be used on the decorated handler.
Interface and Documentation Improvements:
libraries/src/AWS.Lambda.Powertools.Metrics/IMetrics.cs: Improved documentation for methods and parameters, and updated method signatures to provide default values for parameters.Configuration and Initialization Enhancements:
libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs: Introduced a newConfiguremethod to set up theMetricsinstance with options, and added a staticInstanceproperty for easier access. Updated the class to reflect these changes and added new properties and methods to support the configuration options. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Metrics Aspect Refactoring:
libraries/src/AWS.Lambda.Powertools.Metrics/Internal/MetricsAspect.cs: Updated theBeforemethod to use the newConfiguremethod for setting up theMetricsinstance and refactored the cold start metric handling to use the new configuration options. [1] [2]Minor Code Cleanups:
libraries/src/AWS.Lambda.Powertools.Metrics/Internal/MetricsAspect.cs: Removed unnecessaryusingstatements.libraries/src/AWS.Lambda.Powertools.Metrics/Metrics.cs: Added missingusingstatements forSystem.DiagnosticsandSystem.Threading.These changes collectively improve the flexibility, readability, and maintainability of the
AWS.Lambda.Powertools.Metricslibrary.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.