1.30
Summary
In this release we are excited to announce a new major release for Metrics
2.0.0 utility and a new Metrics.AspNetCore
package that allows Metrics
to work with Asp.Net projects (minimal api).
We are also releasing a fix to Logging utility, thanks @gregsinclair42 for reporting and contributing a fix. 🥇
Metrics v2.0.0: A major update introducing enhanced flexibility in metrics handling and new initialization patterns NuGet
Metrics.AspNetCore 0.1.0: New package enabling seamless integration with ASP.NET Core projects NuGet - Developer preview
Logging 1.6.5: Improved stability and enhanced Lambda context handling NuGet
Metrics 2.0.0
This new major version of Metrics brings some breaking changes to be aware of when considering a move from v1:
Breaking Changes (Action Required) Docs
Change | Before (v1.x) | After (v2.0) | Migration Action |
---|---|---|---|
Dimensions format | Array of objects: ["service", "Environment"] |
Array of arrays: [["service", "Environment"]] |
Update code that processes dimension outputs |
FunctionName dimension | Added as default dimension to all metrics | Added only to cold start metric | If you relied on FunctionName in all metrics, add it manually |
Cold Start metrics | Default dimensions excluded | Default dimensions included | Update metric queries if you relied on absence of dimensions |
PushSingleMetrics parameters | metricName , defaultDimensions |
name , dimensions |
Update parameter names in method calls |
New features
Environment Variable Control
New: Use POWERTOOLS_METRICS_DISABLED
to disable Metrics functionality completely.
Two new ways of creating a Metrics instance:
Configure Pattern
Builder Pattern
####Adding default dimensions with cold start metric
You can use the Builder or Configure patterns in your Lambda class constructor to set default dimensions.
Push single Metric
Improved: The PushSingleMetric method now publishes completely isolated metrics without dimensions by default.
Benefits:
- Creates metrics that are unaffected by global configuration
- Enables one-off metrics without changing your default setup
Options for adding dimensions:
- Add specific dimensions: dimensions parameter
- Reuse global dimensions:
- Static approach: Metrics.DefaultDimensions
- Instance approach: Options.DefaultDimensions
Cold start function name
You can now customize the FunctionName dimension in Cold Start metrics.
This is useful where you want to maintain the same name in case of auto generated handler names (cdk, top-level statement functions, etc.)
AspNetCore support (Developer preview)
The new AWS.Lambda.Powertools.Metrics.AspNetCore package enables seamless metrics collection in ASP.NET Core applications running on Lambda.
Installation
dotnet add package AWS.Lambda.Powertools.Metrics.AspNetCore
Integration Options
Choose between two approaches for adding metrics to your ASP.NET Core Lambda application:
UseMetrics Middleware
The UseMetrics middleware is an extension method for the IApplicationBuilder interface.
It adds a metrics middleware to the specified application builder, which captures cold start metrics (if enabled) and flushes metrics on function exit.
WithMetrics Filter
The WithMetrics method is an extension method for the RouteHandlerBuilder class.
It adds a metrics filter to the specified route handler builder, which captures cold start metrics (if enabled) and flushes metrics on function exit.
Testing improvements
To test your code that uses the Metrics utility, you can use the TestLambdaContext class from the Amazon.Lambda.TestUtilities package.
You can now use the IMetrics interface to mock the Metrics utility in your tests.
Logging 1.6.5
Issue Fixed
Improved validation of ILambdaContext parameters regardless of position in method signature.
Before: The Logging utility only checked if ILambdaContext was null when it was the first parameter.
After: The utility now properly validates ILambdaContext at any position in the method signature.
Benefits
- Simplified testing: Unit tests can now pass null for ILambdaContext parameters
- More robust error handling: Prevents runtime exceptions when invalid contexts are provided
- Consistent behavior: Context validation works the same way regardless of parameter position
User experience
Previously, unit tests could be hard to write if a method we call had the [Logging] attribute on it, because then we had to ensure the LambdaContext was set and valid. Now we don't have to worry about the lambda context and can just focus on the code.
This would occur if there was a method like:
Changes
📜 Documentation updates
- chore(deps): bump jinja2 from 3.1.5 to 3.1.6 in /docs (#804) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
2615302
to047452c
in /docs (#801) by @dependabot[bot] - chore(metrics): Fix low hanging fruit for v2 (#800) by @hjgraca
- chore: Metrics disabled environment variable (#786) by @hjgraca
- chore: Metrics set custom FunctionName cold start dimension (#785) by @hjgraca
- chore: Metrics PushSingleMetric default dimensions (#780) by @hjgraca
- chore: Metrics AspNetCore support (#775) by @hjgraca
- chore: Add sitemap to documentation website (#767) by @hjgraca
- chore(deps): bump squidfunk/mkdocs-material from
f5bcec4
to2615302
in /docs (#770) by @dependabot[bot] - fix(ci): Permissions and depdendencies (#772) by @sthulb
- chore(deps): bump squidfunk/mkdocs-material from
c62453b
tof5bcec4
in /docs (#764) by @dependabot[bot]
🐛 Bug and hot fixes
- fix: Metrics e2e tests (#802) by @hjgraca
- fix(logging): check if ILambdaContext is valid in LoggingLambdaContext.Extract (#791) by @gregsinclair42
- fix(ci): add write for issues (#789) by @sthulb
- fix(ci): Add permissions to read issues and pull requests (#788) by @sthulb
- fix(ci): Indentation issue (on_label_added) (#787) by @sthulb
- fix(ci): Permissions (#782) by @sthulb
- fix(ci): Permissions and depdendencies (#772) by @sthulb
🔧 Maintenance
- chore: Update version of logging for release (#811) by @hjgraca
- chore: add contents: write to release drafter (#810) by @hjgraca
- chore: Metrics v2 always set namespace and service (#807) by @hjgraca
- chore(deps): bump jinja2 from 3.1.5 to 3.1.6 (#805) by @dependabot[bot]
- chore(deps): bump jinja2 from 3.1.5 to 3.1.6 in /docs (#804) by @dependabot[bot]
- fix: Metrics e2e tests (#802) by @hjgraca
- chore(deps): bump squidfunk/mkdocs-material from
2615302
to047452c
in /docs (#801) by @dependabot[bot] - chore(metrics): Fix low hanging fruit for v2 (#800) by @hjgraca
- chore: Update GitHub workflows from main to develop (#799) by @hjgraca
- chore: Remove trailing comma (#797) by @hjgraca
- chore(deps): bump codecov/codecov-action from 5.3.1 to 5.4.0 (#793) by @dependabot[bot]
- chore: Metrics disabled environment variable (#786) by @hjgraca
- chore: Metrics set custom FunctionName cold start dimension (#785) by @hjgraca
- chore: Metrics PushSingleMetric default dimensions (#780) by @hjgraca
- chore: Metrics AspNetCore support (#775) by @hjgraca
- chore: Feature/metrics default dimensions coldstart (#771) by @hjgraca
- chore: Add openssf scorecard badge to readme (#790) by @hjgraca
- fix(ci): add write for issues (#789) by @sthulb
- fix(ci): Add permissions to read issues and pull requests (#788) by @sthulb
- fix(ci): Indentation issue (on_label_added) (#787) by @sthulb
- fix(ci): Permissions (#782) by @sthulb
- chore: Add sitemap to documentation website (#767) by @hjgraca
- chore(deps): bump github/codeql-action from 3.28.9 to 3.28.10 (#778) by @dependabot[bot]
- chore(deps): bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#777) by @dependabot[bot]
- chore(deps): bump actions/upload-artifact from 4.6.0 to 4.6.1 (#776) by @dependabot[bot]
- fix(ci): Workflow permissions (#774) by @sthulb
- chore(deps): bump squidfunk/mkdocs-material from
f5bcec4
to2615302
in /docs (#770) by @dependabot[bot] - fix(ci): Permissions and depdendencies (#772) by @sthulb
- chore: FIx Metrics - Add missing array to wrap metrics array (#666) by @hjgraca
- chore(deps): bump zgosalvez/github-actions-ensure-sha-pinned-actions from 3.0.21 to 3.0.22 (#768) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from
c62453b
tof5bcec4
in /docs (#764) by @dependabot[bot]
This release was made possible by the following contributors:
@dependabot[bot], @gregsinclair42, @hjgraca, @leandrodamascena, @sthulb and dependabot[bot]