Skip to content

chore: Sync main with develop #551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4a800c6
Handle Exceptions and Prevent application from crashing when using Lo…
hjgraca Jan 5, 2024
5159cd8
fix test because of order of execution might fail
hjgraca Jan 5, 2024
597a3fb
chore(deps): bump gitpython from 3.1.37 to 3.1.41
dependabot[bot] Jan 10, 2024
3e561d8
chore(deps): bump jinja2 from 3.1.2 to 3.1.3
dependabot[bot] Jan 11, 2024
19884ba
Update build.yml matrix dotnet8
hjgraca Jan 17, 2024
7f380d2
oh yaml formatting
hjgraca Jan 17, 2024
bfe7aaa
add stepid
hjgraca Jan 17, 2024
5d3c0b3
Update Directory.Build.props - remove target framework
hjgraca Jan 17, 2024
0df9271
update target frameworks. delete global.json
hjgraca Jan 17, 2024
f5266b1
revert matrix and add both sdks
hjgraca Jan 17, 2024
675d6ee
update setup title. update examples for multi target framework
hjgraca Jan 17, 2024
1a490e9
with restore in test
hjgraca Jan 17, 2024
a72a612
remove restore. codecov in framework path
hjgraca Jan 18, 2024
3b20c09
trying to bring back --no-restore. Fixing test path
hjgraca Jan 18, 2024
4e6ca8f
restore again
hjgraca Jan 18, 2024
98e0e92
revert test. update -r to --results-directory ../../codecov. https://…
hjgraca Jan 18, 2024
42e1582
fix path codecov
hjgraca Jan 18, 2024
959db8e
Update tracing.md
hjgraca Jan 18, 2024
c513fff
Merge pull request #544 from aws-powertools/hjgraca-docs-auto-disable…
hjgraca Jan 23, 2024
c4c84b7
Merge pull request #540 from aws-powertools/dependabot/pip/jinja2-3.1.3
hjgraca Jan 23, 2024
14d4bcc
Merge pull request #539 from aws-powertools/dependabot/pip/gitpython-…
hjgraca Jan 23, 2024
43a50f1
Merge pull request #542 from hjgraca/dotnet8-support
hjgraca Jan 24, 2024
1be562f
Update batch-processing docs
hjgraca Feb 5, 2024
a331cb3
fix upper snake case to camel case.
H1Gdev Feb 15, 2024
b2af7d7
Merge pull request #548 from H1Gdev/doc
hjgraca Feb 16, 2024
741bff4
Merge pull request #547 from aws-powertools/hjgraca-batch-docs
hjgraca Feb 16, 2024
efec6fb
Merge pull request #538 from hjgraca/hendle-exception-logger
hjgraca Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup .NET 6.0
- name: Setup .NET 6.0 & 8.0
uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a
with:
dotnet-version: 6.0.405
- name: Install solution dependencies
run: dotnet restore
dotnet-version: |
6.0.405
8.0.101
- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet build --configuration Release
- name: Test Examples
run: dotnet test ../examples/
- name: Test & Code Coverage
run: dotnet test --collect:"XPlat Code Coverage" -r ./codecov --no-restore --verbosity normal
run: dotnet test --collect:"XPlat Code Coverage" --results-directory ./codecov --verbosity normal
- name: Codecov
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # 3.1.0
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/core/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ for known event sources, where either a request ID or X-Ray Trace ID are present
*/
public class Function
{
[Logging(CorrelationIdPath = CorrelationIdPaths.API_GATEWAY_REST)]
[Logging(CorrelationIdPath = CorrelationIdPaths.ApiGatewayRest)]
public async Task<APIGatewayProxyResponse> FunctionHandler
(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
{
Expand Down
1 change: 1 addition & 0 deletions docs/core/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ a provides functionality to reduce the overhead of performing common tracing tas
* Capture function responses and full exceptions as metadata.
* Better experience when developing with multiple threads.
* Auto-patch supported modules by AWS X-Ray
* Auto-disable when not running in AWS Lambda environment

## Installation

Expand Down
14 changes: 14 additions & 0 deletions docs/utilities/batch-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ This behavior changes when you enable Report Batch Item Failures feature in your

You can find more details on how Lambda works with either [SQS](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html){target="_blank"}, [Kinesis](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html){target="_blank"}, or [DynamoDB](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html){target="_blank"} in the AWS Documentation.

## Installation

You should install with NuGet:

```powershell
Install-Package AWS.Lambda.Powertools.BatchProcessing
```

Or via the .NET Core command line interface:

```bash
dotnet add package AWS.Lambda.Powertools.BatchProcessing
```

## Getting started

For this feature to work, you need to **(1)** configure your Lambda function event source to use `ReportBatchItemFailures`, and **(2)** return [a specific response](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting){target="_blank" rel="nofollow"} to report which records failed to be processed.
Expand Down
2 changes: 1 addition & 1 deletion examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion examples/Idempotency/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion examples/Logging/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion examples/Metrics/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
<RootNamespace>HelloWorld.Cfn</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion examples/Parameters/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultContentItems>False</EnableDefaultContentItems>
Expand Down
2 changes: 1 addition & 1 deletion examples/Tracing/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
Expand Down
5 changes: 0 additions & 5 deletions global.json

This file was deleted.

52 changes: 33 additions & 19 deletions libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
*
* http://aws.amazon.com/apache2.0
*
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
Expand Down Expand Up @@ -187,7 +187,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, Exception excepti
#region ExtraKeys Logger Extentions

#region Debug

/// <summary>
/// Formats and writes a debug log message.
/// </summary>
Expand Down Expand Up @@ -242,15 +242,16 @@ public static void LogDebug<T>(this ILogger logger, T extraKeys, Exception excep
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.LogDebug(extraKeys, "Processing request from {Address}", address)</example>
public static void LogDebug<T>(this ILogger logger, T extraKeys, string message, params object[] args) where T : class
public static void LogDebug<T>(this ILogger logger, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, LogLevel.Debug, extraKeys, message, args);
}

#endregion

#region Trace

/// <summary>
/// Formats and writes a trace log message.
/// </summary>
Expand Down Expand Up @@ -305,15 +306,16 @@ public static void LogTrace<T>(this ILogger logger, T extraKeys, Exception excep
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.LogTrace(extraKeys, "Processing request from {Address}", address)</example>
public static void LogTrace<T>(this ILogger logger, T extraKeys, string message, params object[] args) where T : class
public static void LogTrace<T>(this ILogger logger, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, LogLevel.Trace, extraKeys, message, args);
}

#endregion

#region Information

/// <summary>
/// Formats and writes an informational log message.
/// </summary>
Expand Down Expand Up @@ -368,11 +370,12 @@ public static void LogInformation<T>(this ILogger logger, T extraKeys, Exception
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.LogInformation(extraKeys, "Processing request from {Address}", address)</example>
public static void LogInformation<T>(this ILogger logger, T extraKeys, string message, params object[] args) where T : class
public static void LogInformation<T>(this ILogger logger, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, LogLevel.Information, extraKeys, message, args);
}

#endregion

#region Warning
Expand Down Expand Up @@ -431,11 +434,12 @@ public static void LogWarning<T>(this ILogger logger, T extraKeys, Exception exc
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.LogWarning(extraKeys, "Processing request from {Address}", address)</example>
public static void LogWarning<T>(this ILogger logger, T extraKeys, string message, params object[] args) where T : class
public static void LogWarning<T>(this ILogger logger, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, LogLevel.Warning, extraKeys, message, args);
}

#endregion

#region Error
Expand Down Expand Up @@ -494,7 +498,8 @@ public static void LogError<T>(this ILogger logger, T extraKeys, Exception excep
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.LogError(extraKeys, "Processing request from {Address}", address)</example>
public static void LogError<T>(this ILogger logger, T extraKeys, string message, params object[] args) where T : class
public static void LogError<T>(this ILogger logger, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, LogLevel.Error, extraKeys, message, args);
}
Expand Down Expand Up @@ -557,15 +562,16 @@ public static void LogCritical<T>(this ILogger logger, T extraKeys, Exception ex
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.LogCritical(extraKeys, "Processing request from {Address}", address)</example>
public static void LogCritical<T>(this ILogger logger, T extraKeys, string message, params object[] args) where T : class
public static void LogCritical<T>(this ILogger logger, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, LogLevel.Critical, extraKeys, message, args);
}

#endregion

#region Log

/// <summary>
/// Formats and writes a log message at the specified log level.
/// </summary>
Expand Down Expand Up @@ -630,11 +636,19 @@ public static void Log<T>(this ILogger logger, LogLevel logLevel, T extraKeys, E
/// <param name="message">Format string of the log message in message template format. Example: <c>"User {User} logged in from {Address}"</c></param>
/// <param name="args">An object array that contains zero or more objects to format.</param>
/// <example>logger.Log(LogLevel.Information, extraKeys, "Processing request from {Address}", address)</example>
public static void Log<T>(this ILogger logger, LogLevel logLevel, T extraKeys, string message, params object[] args) where T : class
public static void Log<T>(this ILogger logger, LogLevel logLevel, T extraKeys, string message, params object[] args)
where T : class
{
Log(logger, logLevel, extraKeys, 0, null, message, args);
try
{
Log(logger, logLevel, extraKeys, 0, null, message, args);
}
catch (Exception e)
{
logger.Log(LogLevel.Error, 0, e, "Powertools internal error");
}
}

#endregion

#endregion
Expand Down
3 changes: 1 addition & 2 deletions libraries/src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>
<PropertyGroup>

<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
<!-- Version is generated when packaging the individual csproj -->
<Version>0.0.1</Version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>default</LangVersion>
<AssemblyName>AWS.Lambda.Powertools.BatchProcessing.Tests</AssemblyName>
<RootNamespace>AWS.Lambda.Powertools.BatchProcessing.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>AWS.Lambda.Powertools.Common.Tests</AssemblyName>
<RootNamespace>AWS.Lambda.Powertools.Common.Tests</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>default</LangVersion>
<AssemblyName>AWS.Lambda.Powertools.Idempotency.Tests</AssemblyName>
<RootNamespace>AWS.Lambda.Powertools.Idempotency.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>default</LangVersion>
<AssemblyName>AWS.Lambda.Powertools.Logging.Tests</AssemblyName>
<RootNamespace>AWS.Lambda.Powertools.Logging.Tests</RootNamespace>
Expand All @@ -12,6 +11,8 @@
<!-- More info https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
<PackageReference Include="Amazon.Lambda.ApplicationLoadBalancerEvents" />
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" />
<PackageReference Include="Amazon.Lambda.Core" />
<PackageReference Include="Amazon.Lambda.TestUtilities" />
<PackageReference Include="coverlet.collector" >
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading