Skip to content

Releases: aws-powertools/powertools-lambda-dotnet

1.17

12 Nov 11:39
46d5b86
Compare
Choose a tag to compare

Summary

AWS Lambda Powertools for .NET - Tracing 1.6.0

🐛 Bug Fixes

  • Fixed a NotSupportedException that occurred when using the Tracing utility in native AOT mode with async methods that don't return a value (Task)
  • Special thanks to @matthewwilson for reporting this issue! ⭐

📦 Package Information

  • Version: 1.6.0
  • Package: AWS.Lambda.Powertools.Tracing

Native AOT Support

Important

To allow Tracing to work with your types in native AOT mode, you must add **WithTracing()** to your source generator configuration. This works with either:

  • The default SourceGeneratorLambdaJsonSerializer
  • The Powertools Logging utility source generator PowertoolsSourceGeneratorSerializer

Tip

For detailed implementation guidelines, please refer to our AOT support documentation.

Implementation Examples

Using Default Source Generator

using AWS.Lambda.Powertools.Tracing;
using AWS.Lambda.Powertools.Tracing.Serializers;

private static async Task Main()
{
    Func<string, ILambdaContext, string> handler = FunctionHandler;
    await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext>()
    .WithTracing())
        .Build()
        .RunAsync();
}

Using Powertools Logging Source Generator

using AWS.Lambda.Powertools.Logging;
using AWS.Lambda.Powertools.Logging.Serializers;
using AWS.Lambda.Powertools.Tracing;
using AWS.Lambda.Powertools.Tracing.Serializers;

private static async Task Main()
{
    Func<string, ILambdaContext, string> handler = FunctionHandler;
    await LambdaBootstrapBuilder.Create(handler, 
        new PowertoolsSourceGeneratorSerializer<LambdaFunctionJsonSerializerContext>()
        .WithTracing())
            .Build()
            .RunAsync();
}

Changes

📜 Documentation updates

  • chore: Tracing Fix async Task Handler exception (#675) by @hjgraca

🔧 Maintenance

  • chore: Tracing Fix async Task Handler exception (#675) by @hjgraca

This release was made possible by the following contributors:

@hjgraca

1.16

22 Oct 09:33
81acc01
Compare
Choose a tag to compare

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:

@nCubed and @hjgraca

1.15

08 Oct 14:46
a979415
Compare
Choose a tag to compare

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.

Batch processing 1.2.0

The ThrowOnFullBatchFailure option can be set via:

  • A new ThrowOnFullBatchFailure field on the BatchProcessor 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

ThrowOnFullBatchFailure attribute usage
ThrowOnFullBatchFailure ProcessingOptions usage

Behavior

When processing of an entire batch fails:

  • If ThrowOnFullBatchFailure is set to false, 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, if ThrowOnFullBatchFailure is set to false, 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

24 Sep 11:33
434add6
Compare
Choose a tag to compare

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.

image

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.

image

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:

@hjgraca

1.13

29 Aug 13:18
4029b08
Compare
Choose a tag to compare

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.

image

📜 Documentation updates

🔧 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:

@dreamorosi, @hjgraca and @leandrodamascena

1.12

25 Jul 13:40
aef100c
Compare
Choose a tag to compare

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

Docs

By default, Tracing uses AWS X-Ray SDK. That means, you must include TrimmerRootAssemblies as part of your .csproj file:

image

Changes

🚀 Features

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@hjgraca

1.11.1

12 Jul 09:47
a1ae03a
Compare
Choose a tag to compare

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

  • chore: Fix metrics lambda context and storage resolution (#613) by @hjgraca

This release was made possible by the following contributors:

@hjgraca

1.11

11 Jul 13:33
33546b4
Compare
Choose a tag to compare

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.

image

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

This release was made possible by the following contributors:

@hjgraca

1.10.1

23 May 10:28
dfd31d4
Compare
Choose a tag to compare

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

  • chore: Metrics - Add thread safety to AddMetric (#594) by @hjgraca

🔧 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:

@hjgraca @jessepoulton-mydeal

1.10.0

09 May 11:33
7a10387
Compare
Choose a tag to compare

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

  • feat(idempotency): add internal powertools JMESPath support (#578) by @hjgraca

📜 Documentation updates

  • feat(idempotency): add internal powertools JMESPath support (#578) by @hjgraca

🔧 Maintenance

This release was made possible by the following contributors:

Code and inspiration from jdevillard/JmesPath.Net and danielaparker/JsonCons.Net

@hjgraca and @amirkaws