Skip to content

Commit

Permalink
Merge pull request #574 from aws-powertools/develop
Browse files Browse the repository at this point in the history
chore: Sync main and develop release 1.9.1
  • Loading branch information
hjgraca authored Mar 21, 2024
2 parents e48cecd + 15efb4c commit d3396b0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
![aws provider](https://img.shields.io/badge/provider-AWS-orange?logo=amazon-aws&color=ff9900)
[![Build](https://github.com/aws-powertools/powertools-lambda-dotnet/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/aws-powertools/powertools-lambda-dotnet/actions/workflows/build.yml)
[![codecov.io](https://codecov.io/github/aws-powertools/powertools-lambda-dotnet/branch/develop/graphs/badge.svg)](https://app.codecov.io/gh/aws-powertools/powertools-lambda-dotnet)
[![dotnet support](https://img.shields.io/static/v1?label=dotnet&message=%20NET6.0&color=blue?style=flat-square&logo=dotnet)](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
[![dotnet support](https://img.shields.io/static/v1?label=dotnet&message=%20NET6.0|NET8.0&color=blue?style=flat-square&logo=dotnet)](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
[![NuGet Downloads](https://img.shields.io/nuget/dt/AWS.Lambda.Powertools.Logging.svg)](https://www.nuget.org/packages?q=AWS.Lambda.Powertools)
[![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET)](https://discord.gg/B8zZKbbyET)
[![Join our Discord](https://dcbadge.vercel.app/api/server/B8zZKbbyET?style=flat-square)](https://discord.gg/B8zZKbbyET)

Powertools for AWS Lambda (.NET) is a developer toolkit to implement Serverless [best practices and increase developer velocity](https://docs.powertools.aws.dev/lambda-dotnet/#features).

Expand Down Expand Up @@ -33,7 +33,7 @@ Powertools for AWS Lambda (.NET) provides three core utilities:

### Installation

The Powertools for AWS Lambda (.NET) utilities (.NET 6) are available as NuGet packages. You can install the packages from [NuGet Gallery](https://www.nuget.org/packages?q=AWS+Lambda+Powertools*) or from Visual Studio editor by searching `AWS.Lambda.Powertools*` to see various utilities available.
The Powertools for AWS Lambda (.NET) utilities (.NET 6 and .NET 8) are available as NuGet packages. You can install the packages from [NuGet Gallery](https://www.nuget.org/packages?q=AWS+Lambda+Powertools*) or from Visual Studio editor by searching `AWS.Lambda.Powertools*` to see various utilities available.

* [AWS.Lambda.Powertools.Logging](https://www.nuget.org/packages?q=AWS.Lambda.Powertools.Logging):

Expand Down Expand Up @@ -61,7 +61,7 @@ The Powertools for AWS Lambda (.NET) utilities (.NET 6) are available as NuGet p

## Examples

We have provided examples focused specifically on each of the utilities. Each solution comes with an AWS Serverless Application Model (AWS SAM) templates to run your functions as a Zip package using the AWS Lambda .NET 6 managed runtime; or as a container package using the AWS base images for .NET.
We have provided examples focused specifically on each of the utilities. Each solution comes with an AWS Serverless Application Model (AWS SAM) templates to run your functions as a Zip package using the AWS Lambda .NET 6 or .NET 8 managed runtime; or as a container package using the AWS base images for .NET.

* **[Logging example](examples/Logging/)**
* **[Metrics example](examples/Metrics/)**
Expand Down
5 changes: 4 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ description: Powertools for AWS Lambda (.NET)

# Powertools for AWS Lambda (.NET)

Powertools for AWS Lambda (.NET) (which from here will be referred as Powertools) is a suite of utilities for [AWS Lambda](https://aws.amazon.com/lambda/) functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. Please note, **Powertools for AWS Lambda (.NET) is optimized for .NET 6+**.
Powertools for AWS Lambda (.NET) (which from here will be referred as Powertools) is a suite of utilities for [AWS Lambda](https://aws.amazon.com/lambda/) functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more.

!!! info
**Supports .NET 6 and .NET 8 runtimes**

???+ tip
Powertools is also available for [Python](https://docs.powertools.aws.dev/lambda/python/){target="_blank"}, [Java](https://docs.powertools.aws.dev/lambda/java/){target="_blank"}, and [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/){target="_blank"}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public object Handle(
};

var wrappers = triggers.OfType<UniversalWrapperAttribute>().ToArray();
var handler = GetMethodHandler(method, returnType, wrappers);
// Target.Method is more precise for cases when decorating generic methods
var handler = GetMethodHandler(target.Method, returnType, wrappers);
return handler(target, args, eventArgs);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Globalization;
using System.Threading.Tasks;

namespace AWS.Lambda.Powertools.Tracing.Tests.Handlers;

public class FunctionHandlerForGeneric
{
[Tracing(CaptureMode = TracingCaptureMode.ResponseAndError)]
public async Task<string> Handle(string input)
{
GenericMethod<int>(1);
GenericMethod<double>(2);

GenericMethod<int>(1);

GenericMethod<int>();
GenericMethod<double>();

GenericMethod2<int>(1);
GenericMethod2<double>(2);

GenericMethod<int>();
GenericMethod<double>();

await Task.Delay(1);

return input.ToUpper(CultureInfo.InvariantCulture);
}

[Tracing]
private T GenericMethod<T>(T x)
{
return default;
}

[Tracing]
private T GenericMethod<T>()
{
return default;
}

[Tracing]
private void GenericMethod2<T>(T x)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace AWS.Lambda.Powertools.Tracing.Tests.Handlers;

public sealed class ExceptionFunctionHandlerTests
public sealed class HandlerTests
{
[Fact]
public async Task Stack_Trace_Included_When_Decorator_Present()
Expand All @@ -20,4 +20,17 @@ public async Task Stack_Trace_Included_When_Decorator_Present()
Assert.StartsWith("at AWS.Lambda.Powertools.Tracing.Tests.Handlers.ExceptionFunctionHandler.ThisThrows()", tracedException.StackTrace?.TrimStart());

}

[Fact]
public async Task When_Decorator_Present_In_Generic_Method_Should_Not_Throw_When_Type_Changes()
{
// Arrange
var handler = new FunctionHandlerForGeneric();

// Act
await handler.Handle("whatever");

// Assert

}
}

0 comments on commit d3396b0

Please sign in to comment.