Releases: aws-powertools/powertools-lambda-dotnet
1.16
Summary
In this release we have fixed an issue with Enum serialization.
The fix addresses an edge case where enum values weren't properly serialized when using C# top-level statements (file-scoped namespaces) in Lambda functions. This ensures proper logging functionality regardless of your chosen code structure.
Logging version: 1.6.2
- Fixed Enum serialization when using top-level statements in Lambda functions
- Resolves incorrect enum value handling in structured logging
- Ensures consistent logging behavior across different Lambda function styles
Special thanks to @nCubed for:
- Reporting the issue
- Providing detailed reproduction steps
- Assisting with troubleshooting and validation
Changes
🐞 Fixes
This release was made possible by the following contributors:
1.15
Summary
In this release we are excited to announce a new feature in the Batch processing utility and bug fixes in Tracing and Logging.
New Feature: ThrowOnFullBatchFailure
This release introduces a new batch processing option: ThrowOnFullBatchFailure
. This option controls whether a BatchProcessingException
should be raised on full batch failure.
⭐ Special thanks to @lachriz-aws for developing this feature.
The ThrowOnFullBatchFailure
option can be set via:
- A new
ThrowOnFullBatchFailure
field on theBatchProcessor
attribute (applied in non-utility mode) - A new environment variable
POWERTOOLS_BATCH_THROW_ON_FULL_BATCH_FAILURE
(applied in non-utility mode) - Directly on the
AWS.Lambda.Powertools.BatchProcessing.ProcessingOptions
in utility mode
Behavior
When processing of an entire batch fails:
- If
ThrowOnFullBatchFailure
is set tofalse
, the Batch Processor will not throw an exception after batch processing has completed. Instead, it will return the IDs of the failed items (all batch items in this case) and exit gracefully. - If a Lambda function is configured with
ErrorHandlingPolicy = StopOnFirstBatchItemFailure
and the first batch item fails processing, the entire batch is marked as failed (as per the documentation). In this case, ifThrowOnFullBatchFailure
is set tofalse
, the behavior described above will apply.
Note: The new ThrowOnFullBatchFailure
option is compatible with the existing error handling policies.
Bug Fixes
Tracing Update
- Updated to version 1.5.2
- Fixed issue #659: Lambda timeout when calling async methods from a
Tracing
decorated method in version 1.5.1 - Thanks to @JonathanVerberne for reporting this issue
Logging Update
- Updated to version 1.6.1
- Fixed issue #656: Serialization exceptions when running .NET 8 non-AOT Lambda functions
- Thanks to @nCubed for reporting this issue
Changes
🌟New features and non-breaking changes
- feat: New batch processing option: 'ThrowOnFullBatchFailure' (#646) by @lachriz-aws
📜 Documentation updates
- feat: New batch processing option: 'ThrowOnFullBatchFailure' (#646) by @lachriz-aws
🔧 Bug Fixes
- chore: Fix Lambda timeout with Tracing 1.5.1 using async methods (#660) by @hjgraca
- chore: Remove TypeInfoResolver from non AOT mode. (#657) by @hjgraca
- chore: update logging nuget package version v 1.6.0 (#652) by @hjgraca
This release was made possible by the following contributors:
@hjgraca and @lachriz-aws
1.14
Summary
We are excited to announce GA support for Ahead-of-Time (AOT) compilation for Logging version 1.6.0. You can now use Logging in your AOT-published .NET AWS Lambda functions without any AOT warnings.
With this release, all Powertools core utilities (Logging, Metrics, and Tracing) have AOT support.
You can follow progress on AOT support here.
Check our docs for AOT support details.
Tip
New to AOT?
Check out this tutorial in the AWS Lambda documentation.
Serialization
Important
Starting from version 1.6.0, it is required to update the Amazon.Lambda.Serialization.SystemTextJson
NuGet package to version 2.4.3
in your csproj
.
Note
Using LogEvent
, Custom Log Formatter
features, or serialize your own types when Logging events? You need to make changes in your Lambda Main
method.
Replace SourceGeneratorLambdaJsonSerializer
with PowertoolsSourceGeneratorSerializer
.
When you update your code to use PowertoolsSourceGeneratorSerializer<MyCustomJsonSerializerContext>
, we combine your JsonSerializerContext
with Powertools' JsonSerializerContext
. This allows Powertools to serialize your types and Lambda events.
Custom Log Formatter
Important
To use a custom log formatter with AOT, pass an instance of ILogFormatter
to PowertoolsSourceGeneratorSerializer
instead of using the static Logger.UseFormatter
in the Function constructor as you do in non-AOT Lambdas.
Anonymous Types
While we support anonymous type serialization by converting to a Dictionary<string, object>
, this is not a best practice and is not recommended when using native AOT.
We recommend using concrete classes and adding them to your JsonSerializerContext
.
Changes
🚀 Features
📜 Documentation updates
🔧 Maintenance
- chore: Update examples for release 1..13 (#645) by @hjgraca
- chore: Refactor and simplify Common dependency. (#643) by @hjgraca
- chore: Change the way we reference Common and JMESPath (internal references). (#641) by @hjgraca
This release was made possible by the following contributors:
1.13
Summary
In this release we fix a bug when using Tracing utility with BatchProcessing utility.
The issue occurred due a max depth serialization error when using Batch RecordHanderResult and Tracing decorator
Special thanks to @CoreySchnedl for reporting the issue
New in this release
We also improved the user experience in case any other serialization error occurs.
Now when exceptions occour inside X-Ray SDK EndSubsegment we catch those and create a new SubSegment in CloudWatch Traces, this prevents the app from crashing and displays in the UI that an error occurred.
📜 Documentation updates
- chore: fix docs missing closing tag (#639) by @hjgraca
- chore(docs): Updating tracing docs for typo (#622) by @hjgraca
- chore(docs): load self hosted mermaid.js (#635) by @dreamorosi
- chore: Add Pushpay as a public reference (#633) by @hjgraca
- chore: add caylent as a public reference (#625) by @hjgraca
🔧 Maintenance
- chore: fix docs missing closing tag (#639) by @hjgraca
- chore: Update versions for release 1.13 (#638) by @hjgraca
- chore(docs): Updating tracing docs for typo (#622) by @hjgraca
- chore(docs): load self hosted mermaid.js (#635) by @dreamorosi
- chore: Fix Max depth serialization bug when using Batch RecordHanderResult and Tracing (#632) by @hjgraca
- chore: Add Pushpay as a public reference (#633) by @hjgraca
- chore: add caylent as a public reference (#625) by @hjgraca
- chore: Update examples Tracing to version 1.5.0 related to release 1.12 (#623) by @hjgraca
- chore: Change the way we reference Common and JMESPath (internal references). (#641) by @hjgraca
- Bug: Issue with JMESPath dependency in Idempotency on some scenarios (#626) by @hjgraca
- chore: Refactor and simplify Common dependency. (#643) by @hjgraca
This release was made possible by the following contributors:
1.12
Summary
We are excited to announce GA support for Ahead-of-time (AOT) compilation for Tracing version 1.5.0. This means, you can now use Tracing in your AOT published .NET AWS Lambda functions without any AOT warnings.
You can follow progress on AOT support here.
Tip
New to AOT?
Checkout this tutorial in the AWS Lambda documentation.
Caveats
By default, Tracing uses AWS X-Ray SDK. That means, you must include TrimmerRootAssemblies as part of your .csproj file:
Changes
🚀 Features
📜 Documentation updates
🔧 Maintenance
- chore(deps-dev): bump zipp from 3.11.0 to 3.19.1 (#610) by @dependabot
- chore: update examples for release 1.11.1 (#617) by @hjgraca
This release was made possible by the following contributors:
1.11.1
Summary
This release we fix a regression caused by release 1.7.0.
This bug caused the Metrics to not capture the Lambda context when in an AOT published Lambda.
Version 1.7.0 was removed from NuGet
Changes
{
"_aws": {
"Timestamp": 1720714102216,
"CloudWatchMetrics": [
{
"Namespace": "ns",
"Metrics": [
{
"Name": "ColdStart",
"Unit": "Count"
}
],
"Dimensions": [
[
"FunctionName"
],
[
"Service"
]
]
}
]
},
"FunctionName": null, <--- should not be null
"Service": "svc",
"ColdStart": 1
}
🔧 Maintenance
This release was made possible by the following contributors:
1.11
Summary
In this release we are happy to announce GA support for Ahead-of-time (AOT) compilation for Metrics version 1.7.0.
Now it is possible to use Metrics on your AOT published .NET AWS Lambda functions without any AOT warnings.
We have been working on this support for the last few months and before going GA we made the version 1.7.0-alpha available for users to test and no issues were reported.
We continue hard at work on adding AOT support to all utilities by the end of this year.
The following example shows how to use Metrics in an AOT-enabled Lambda function.
If you want to get started or learn more about AOT go to the following tutorial on how to build .NET Lambda functions with Native AOT compilation.
🚀 Features
📜 Documentation updates
🔧 Maintenance
- chore(deps): bump jinja2 from 3.1.3 to 3.1.4 (#579) by @dependabot
- chore: Update codecov (#605) by @hjgraca
- chore: Update examples for release 1.10.1 (#600) by @hjgraca
This release was made possible by the following contributors:
1.10.1
Summary
In this release we fix a bug in Metrics caused when using Metrics utility in Multi threaded scenarios and the PowertoolsConfigurations.MaxMetrics was a lower number. #593
Fix release in version 1.6.2 of Metrics
Thanks to @jessepoulton-mydeal for reporting the issue.
Changes
🐛 Bug and hot fixes
🔧 Maintenance
- chore: Fix jmespath dependency (#590) by @hjgraca
- chore: Update idempotency examples for release 1..10.0 (#589) by @hjgraca
This release was made possible by the following contributors:
1.10.0
Summary
In this release we introduce built in JMESPath support for Powertools Idempotency utility.
With this release we remove the need for 3rd party dependencies and move from the old Newtonsoft.Json
to the new System.Text.Json
also is fully JMESPath spec compliant.
Fully backwards compatible, there are no changes to the way you having been using Idempotency before.
Nuget verstion: Idempotency 1.2.1
Powertools JMESPath functions
You can use our built-in JMESPath functions within your envelope expression. They handle deserialization for common data formats found in AWS Lambda event sources such as JSON strings, base64, and uncompress gzip data.
powertools_json function idempotency example
Use powertools_json function to decode any JSON string anywhere a JMESPath expression is allowed.
Example of using JMESPath with Idempotency to create the idempotent key
Idempotency.Configure(builder =>
builder
.WithOptions(optionsBuilder =>
optionsBuilder.WithEventKeyJmesPath("powertools_json(Body).[\"user_id\", \"product_id\"]"))
.UseDynamoDb("idempotency_table"));
{
"version": "2.0",
"routeKey": "ANY /createpayment",
"rawPath": "/createpayment",
"rawQueryString": "",
"headers": {
"Header1": "value1",
"Header2": "value2"
},
"requestContext": {
"accountId": "123456789012",
"apiId": "api-id",
"domainName": "id.execute-api.us-east-1.amazonaws.com",
"domainPrefix": "id",
"http": {
"method": "POST",
"path": "/createpayment",
"protocol": "HTTP/1.1",
"sourceIp": "ip",
"userAgent": "agent"
},
"requestId": "id",
"routeKey": "ANY /createpayment",
"stage": "$default",
"time": "10/Feb/2021:13:40:43 +0000",
"timeEpoch": 1612964443723
},
"body": "{\"user_id\":\"xyz\",\"product_id\":\"123456789\"}",
"isBase64Encoded": false
}
Changes
🌟New features and non-breaking changes
📜 Documentation updates
🔧 Maintenance
- docs: add link to Powertools for AWS Lambda workshop (#581) by @dreamorosi
- chore: Update build pipeline (#584) by @hjgraca
This release was made possible by the following contributors:
Code and inspiration from jdevillard/JmesPath.Net and danielaparker/JsonCons.Net
1.9.1
Summary
In this release we fix an issue that was causing a System.InvalidCastException
exception when decorating with the Tracing attribute generic methods that would be called with different T as parameters or return T.
Thank you @Kuling for reporting the issue.
using Amazon.Lambda.APIGatewayEvents;
using Amazon.Lambda.Core;
using AWS.Lambda.Powertools.Tracing;
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace MyFunction
{
public interface ISampleService
{
Task<T> LoadAsync<T>(T query);
}
[Tracing]
public class SampleService : ISampleService
{
public async Task<T> LoadAsync<T>(T query)
{
return default;
}
}
[Tracing]
public class Function
{
public async Task<APIGatewayProxyResponse> FunctionHandlerAsync(APIGatewayProxyRequest request, ILambdaContext context)
{
var target = new SampleService();
await target.LoadAsync<double>(3.4);
await target.LoadAsync<int>(5); // Bug
return null;
}
}
}