Skip to content

Releases: aws-powertools/powertools-lambda-dotnet

1.14

24 Sep 11:33
434add6

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

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

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

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

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

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

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

1.9.1

21 Mar 11:08
ff53f97

Choose a tag to compare

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;
        }
    }
}

Changes

📜 Documentation updates

  • chore(docs): Update docs and add supported runtimes (#569) by @hjgraca

🐛 Bug and hot fixes

  • fix: Error when decorating duplicate generic method - Tracing (#572) by @hjgraca

🔧 Maintenance

  • chore(docs): Update docs and add supported runtimes (#569) by @hjgraca

This release was made possible by the following contributors:

@Kuling and @hjgraca

1.9.0

11 Mar 09:50
9288404

Choose a tag to compare

Summary

With this release, we add feature to existing Parameters to retrieve values from AWS AppConfig.

using AWS.Lambda.Powertools.Parameters;
using AWS.Lambda.Powertools.Parameters.AppConfig;

public class Function
{
    public async Task<APIGatewayProxyResponse> FunctionHandler
        (APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
    {
        // Get AppConfig Provider instance
        IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
            .DefaultApplication("MyApplicationId")
            .DefaultEnvironment("MyEnvironmentId")
            .DefaultConfigProfile("MyConfigProfileId");
        
        // Retrieve a single configuration, latest version
        IDictionary<string, string?> value = await appConfigProvider
            .GetAsync()
            .ConfigureAwait(false);

        //Working with feature flags
        
        // Check if feature flag is enabled
        var isFeatureFlagEnabled = await appConfigProvider
            .IsFeatureFlagEnabledAsync("MyFeatureFlag")
            .ConfigureAwait(false);
        
        if (isFeatureFlagEnabled)
        {
            // Retrieve an attribute value of the feature flag
            var strAttValue = await appConfigProvider
                .GetFeatureFlagAttributeValueAsync<string>("MyFeatureFlag", "StringAttribute")
                .ConfigureAwait(false);
            
            // Retrieve another attribute value of the feature flag
            var numberAttValue = await appConfigProvider
                .GetFeatureFlagAttributeValueAsync<int>("MyFeatureFlag", "NumberAttribute")
                .ConfigureAwait(false);
        }
    }
}

Changes

🌟New features and non-breaking changes

AWS.Lambda.Powertools.Logging - 1.5.1
AWS.Lambda.Powertools.Metrics - 1.6.1
AWS.Lambda.Powertools.Tracing - 1.4.1
AWS.Lambda.Powertools.Parameters - 1.3.0
AWS.Lambda.Powertools.Idempotency - 1.1.1
AWS.Lambda.Powertools.BatchProcessing - 1.1.1

📜 Documentation updates

🔧 Maintenance

This release was made possible by the following contributors:

@amirkaws and @hjgraca

1.8.5

16 Feb 20:11
6286cad

Choose a tag to compare

Summary

In this release we added a "global" exception handler to Logging utility, so that when using the utility the exceptions inside are not sent to the client and break their applications. Instead we write the error message to the logs so the client can act on it.

We also added support for dotnet 8. Now Powertools supports dotnet 6 and dotnet 8, we build packages for both versions.

Changes

AWS.Lambda.Powertools.Logging - 1.5.0
AWS.Lambda.Powertools.Tracing - 1.4.0
AWS.Lambda.Powertools.Metrics - 1.6.0
AWS.Lambda.Powertools.Parameters - 1.2.0
AWS.Lambda.Powertools.Idempotency - 1.1.0
AWS.Lambda.Powertools.BatchProcessing - 1.1.0

📜 Documentation updates

  • chore: Update batch-processing docs (#547) by @hjgraca
  • chore(docs): fix upper snake case to camel case. (#548) by @H1Gdev
  • chore: Update tracing.md - Auto-disable when not running in AWS Lambda environment (#544) by @hjgraca
  • docs: we made this section update (#536) by @sliedig

🐛 Bug and hot fixes

  • fix: Handle Exceptions and Prevent application from crashing when using Logger (#538) by @hjgraca

🔧 Maintenance

  • chore: Update batch-processing docs (#547) by @hjgraca
  • chore(docs): fix upper snake case to camel case. (#548) by @H1Gdev
  • chore: dotnet 8 support (#542) by @hjgraca
  • chore(deps): bump gitpython from 3.1.37 to 3.1.41 (#539) by @dependabot
  • chore(deps): bump jinja2 from 3.1.2 to 3.1.3 (#540) by @dependabot
  • chore: Update tracing.md - Auto-disable when not running in AWS Lambda environment (#544) by @hjgraca

This release was made possible by the following contributors:

@H1Gdev, @hjgraca and @sliedig