diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc25ad50a..e831d3669 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/docs/core/logging.md b/docs/core/logging.md index d4e85f98b..1e6153620 100644 --- a/docs/core/logging.md +++ b/docs/core/logging.md @@ -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 FunctionHandler (APIGatewayProxyRequest apigProxyEvent, ILambdaContext context) { diff --git a/docs/core/tracing.md b/docs/core/tracing.md index 30a709cd4..9815b49a1 100644 --- a/docs/core/tracing.md +++ b/docs/core/tracing.md @@ -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 diff --git a/docs/utilities/batch-processing.md b/docs/utilities/batch-processing.md index 2c3e460bc..eb18eb7c9 100644 --- a/docs/utilities/batch-processing.md +++ b/docs/utilities/batch-processing.md @@ -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. diff --git a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj index 4b4abe012..0589010c1 100644 --- a/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj +++ b/examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@  - net6.0 + net6.0;net8.0 true enable diff --git a/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj index 6403301ae..fe9b08e07 100644 --- a/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/BatchProcessing/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj index 8be19c09c..1b62c992d 100644 --- a/examples/Idempotency/src/HelloWorld/HelloWorld.csproj +++ b/examples/Idempotency/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj index c38d76bdd..6afa095c4 100644 --- a/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Idempotency/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Logging/src/HelloWorld/HelloWorld.csproj b/examples/Logging/src/HelloWorld/HelloWorld.csproj index c99ee06d4..53323ac8d 100644 --- a/examples/Logging/src/HelloWorld/HelloWorld.csproj +++ b/examples/Logging/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj index 31e123cf3..7a5090108 100644 --- a/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Logging/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Metrics/src/HelloWorld/HelloWorld.csproj b/examples/Metrics/src/HelloWorld/HelloWorld.csproj index 8ccb558a7..b3262af29 100644 --- a/examples/Metrics/src/HelloWorld/HelloWorld.csproj +++ b/examples/Metrics/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj index 31e123cf3..7a5090108 100644 --- a/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Metrics/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj b/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj index a46da41e4..cf56c3616 100644 --- a/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj +++ b/examples/Parameters/cfn/HelloWorld.Cfn/HelloWorld.Cfn.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable HelloWorld.Cfn diff --git a/examples/Parameters/src/HelloWorld/HelloWorld.csproj b/examples/Parameters/src/HelloWorld/HelloWorld.csproj index d4fcefec5..d9709c681 100644 --- a/examples/Parameters/src/HelloWorld/HelloWorld.csproj +++ b/examples/Parameters/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj index 8ed6558af..0c7418eb5 100644 --- a/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Parameters/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj index 489c9a7b6..3609e4422 100644 --- a/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj +++ b/examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj @@ -1,7 +1,7 @@ Exe - net6.0 + net6.0;net8.0 enable enable true diff --git a/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj b/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj index 070787b5f..de239d45c 100644 --- a/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj +++ b/examples/ServerlessApi/test/LambdaPowertoolsAPI.Tests/LambdaPowertoolsAPI.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 enable enable False diff --git a/examples/Tracing/src/HelloWorld/HelloWorld.csproj b/examples/Tracing/src/HelloWorld/HelloWorld.csproj index 81a344457..32beb88bb 100644 --- a/examples/Tracing/src/HelloWorld/HelloWorld.csproj +++ b/examples/Tracing/src/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 true enable diff --git a/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj b/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj index 31e123cf3..7a5090108 100644 --- a/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj +++ b/examples/Tracing/test/HelloWorld.Test/HelloWorld.Tests.csproj @@ -1,6 +1,6 @@ - net6.0 + net6.0;net8.0 diff --git a/global.json b/global.json deleted file mode 100644 index 5f5ece165..000000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "6.0.405" - } -} diff --git a/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs b/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs index 8c8dd3110..200cf46ed 100644 --- a/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs +++ b/libraries/src/AWS.Lambda.Powertools.Logging/LoggerExtensions.cs @@ -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 @@ -187,7 +187,7 @@ public static void Log(this ILogger logger, LogLevel logLevel, Exception excepti #region ExtraKeys Logger Extentions #region Debug - + /// /// Formats and writes a debug log message. /// @@ -242,15 +242,16 @@ public static void LogDebug(this ILogger logger, T extraKeys, Exception excep /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogDebug(extraKeys, "Processing request from {Address}", address) - public static void LogDebug(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogDebug(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Debug, extraKeys, message, args); } - + #endregion #region Trace - + /// /// Formats and writes a trace log message. /// @@ -305,7 +306,8 @@ public static void LogTrace(this ILogger logger, T extraKeys, Exception excep /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogTrace(extraKeys, "Processing request from {Address}", address) - public static void LogTrace(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogTrace(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Trace, extraKeys, message, args); } @@ -313,7 +315,7 @@ public static void LogTrace(this ILogger logger, T extraKeys, string message, #endregion #region Information - + /// /// Formats and writes an informational log message. /// @@ -368,11 +370,12 @@ public static void LogInformation(this ILogger logger, T extraKeys, Exception /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogInformation(extraKeys, "Processing request from {Address}", address) - public static void LogInformation(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogInformation(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Information, extraKeys, message, args); } - + #endregion #region Warning @@ -431,11 +434,12 @@ public static void LogWarning(this ILogger logger, T extraKeys, Exception exc /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogWarning(extraKeys, "Processing request from {Address}", address) - public static void LogWarning(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogWarning(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Warning, extraKeys, message, args); } - + #endregion #region Error @@ -494,7 +498,8 @@ public static void LogError(this ILogger logger, T extraKeys, Exception excep /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogError(extraKeys, "Processing request from {Address}", address) - public static void LogError(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogError(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Error, extraKeys, message, args); } @@ -557,7 +562,8 @@ public static void LogCritical(this ILogger logger, T extraKeys, Exception ex /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.LogCritical(extraKeys, "Processing request from {Address}", address) - public static void LogCritical(this ILogger logger, T extraKeys, string message, params object[] args) where T : class + public static void LogCritical(this ILogger logger, T extraKeys, string message, params object[] args) + where T : class { Log(logger, LogLevel.Critical, extraKeys, message, args); } @@ -565,7 +571,7 @@ public static void LogCritical(this ILogger logger, T extraKeys, string messa #endregion #region Log - + /// /// Formats and writes a log message at the specified log level. /// @@ -630,11 +636,19 @@ public static void Log(this ILogger logger, LogLevel logLevel, T extraKeys, E /// Format string of the log message in message template format. Example: "User {User} logged in from {Address}" /// An object array that contains zero or more objects to format. /// logger.Log(LogLevel.Information, extraKeys, "Processing request from {Address}", address) - public static void Log(this ILogger logger, LogLevel logLevel, T extraKeys, string message, params object[] args) where T : class + public static void Log(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 diff --git a/libraries/src/Directory.Build.props b/libraries/src/Directory.Build.props index 4d4afc36c..0260344d5 100644 --- a/libraries/src/Directory.Build.props +++ b/libraries/src/Directory.Build.props @@ -1,7 +1,6 @@ - - net6.0 + net6.0;net8.0 default 0.0.1 diff --git a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj index 0824576d0..d71afc788 100644 --- a/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.BatchProcessing.Tests/AWS.Lambda.Powertools.BatchProcessing.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.BatchProcessing.Tests AWS.Lambda.Powertools.BatchProcessing.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj index 8c5541406..243fbf9d3 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Common.Tests/AWS.Lambda.Powertools.Common.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 AWS.Lambda.Powertools.Common.Tests AWS.Lambda.Powertools.Common.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj index 4dab4f4f1..1ea81cc32 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Idempotency.Tests/AWS.Lambda.Powertools.Idempotency.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.Idempotency.Tests AWS.Lambda.Powertools.Idempotency.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj index 197fec51d..9d49d5145 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/AWS.Lambda.Powertools.Logging.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.Logging.Tests AWS.Lambda.Powertools.Logging.Tests @@ -12,6 +11,8 @@ + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs index a2928252d..230053886 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandler.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; +using Amazon.Lambda.Core; namespace AWS.Lambda.Powertools.Logging.Tests.Handlers; @@ -20,4 +22,34 @@ private void ThisThrows() { throw new NullReferenceException(); } + + [Logging(CorrelationIdPath = "/1//", LogEvent = true, Service = null, SamplingRate = 10000d)] + public string HandlerLoggerForExceptions(string input, ILambdaContext context) + { + // Edge cases and bad code to force exceptions + + Logger.LogInformation("Hello {input}", input); + Logger.LogError("Hello {input}", input); + Logger.LogCritical("Hello {input}", input); + Logger.LogDebug("Hello {input}", input); + Logger.LogTrace("Hello {input}", input); + + Logger.LogInformation("Testing with parameter Log Information Method {company}", new[] { "AWS" }); + + var customKeys = new Dictionary + { + {"test1", "value1"}, + {"test2", "value2"} + }; + Logger.LogInformation(customKeys, "Retrieved data for city {cityName} with count {company}", "AWS"); + + Logger.AppendKey("aws",1); + Logger.AppendKey("aws",3); + + Logger.RemoveKeys("test"); + + Logger.AppendKeys(new[]{ new KeyValuePair("aws",1), new KeyValuePair("aws",2)}); + + return "OK"; + } } \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs index f2bbe798e..dd7a12db8 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/Handlers/ExceptionFunctionHandlerTests.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Amazon.Lambda.TestUtilities; using Xunit; namespace AWS.Lambda.Powertools.Logging.Tests.Handlers; @@ -20,4 +21,19 @@ public async Task Stack_Trace_Included_When_Decorator_Present() Assert.StartsWith("at AWS.Lambda.Powertools.Logging.Tests.Handlers.ExceptionFunctionHandler.ThisThrows()", tracedException.StackTrace?.TrimStart()); } + + [Fact] + public void Utility_Should_Not_Throw_Exceptions_To_Client() + { + // Arrange + var lambdaContext = new TestLambdaContext(); + + var handler = new ExceptionFunctionHandler(); + + // Act + var res = handler.HandlerLoggerForExceptions("aws",lambdaContext); + + // Assert + Assert.Equal("OK", res); + } } \ No newline at end of file diff --git a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs index 82c93e34a..158d8fe8e 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs +++ b/libraries/tests/AWS.Lambda.Powertools.Logging.Tests/LogFormatterTest.cs @@ -138,16 +138,17 @@ public void Log_WhenCustomFormatter_LogsCustomFormat() x.Level == logLevel && x.Message.ToString() == message && x.Exception == null && - x.ExtraKeys != null && - x.ExtraKeys.Count == globalExtraKeys.Count + scopeExtraKeys.Count && - x.ExtraKeys.ContainsKey(globalExtraKeys.First().Key) && - x.ExtraKeys[globalExtraKeys.First().Key] == globalExtraKeys.First().Value && - x.ExtraKeys.ContainsKey(globalExtraKeys.Last().Key) && - x.ExtraKeys[globalExtraKeys.Last().Key] == globalExtraKeys.Last().Value && - x.ExtraKeys.ContainsKey(scopeExtraKeys.First().Key) && - x.ExtraKeys[scopeExtraKeys.First().Key] == scopeExtraKeys.First().Value && - x.ExtraKeys.ContainsKey(scopeExtraKeys.Last().Key) && - x.ExtraKeys[scopeExtraKeys.Last().Key] == scopeExtraKeys.Last().Value && + x.ExtraKeys != null && ( + x.ExtraKeys.Count != globalExtraKeys.Count + scopeExtraKeys.Count || ( + x.ExtraKeys.Count == globalExtraKeys.Count + scopeExtraKeys.Count && + x.ExtraKeys.ContainsKey(globalExtraKeys.First().Key) && + x.ExtraKeys[globalExtraKeys.First().Key] == globalExtraKeys.First().Value && + x.ExtraKeys.ContainsKey(globalExtraKeys.Last().Key) && + x.ExtraKeys[globalExtraKeys.Last().Key] == globalExtraKeys.Last().Value && + x.ExtraKeys.ContainsKey(scopeExtraKeys.First().Key) && + x.ExtraKeys[scopeExtraKeys.First().Key] == scopeExtraKeys.First().Value && + x.ExtraKeys.ContainsKey(scopeExtraKeys.Last().Key) && + x.ExtraKeys[scopeExtraKeys.Last().Key] == scopeExtraKeys.Last().Value ) ) && x.LambdaContext != null && x.LambdaContext.FunctionName == lambdaContext.FunctionName && x.LambdaContext.FunctionVersion == lambdaContext.FunctionVersion && diff --git a/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj index a209a34c0..f6fd9f8d8 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Metrics.Tests/AWS.Lambda.Powertools.Metrics.Tests.csproj @@ -1,14 +1,9 @@ - net6.0 - false - default - AWS.Lambda.Powertools.Metrics.Tests - AWS.Lambda.Powertools.Metrics.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj index 199185679..bae7120f3 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Parameters.Tests/AWS.Lambda.Powertools.Parameters.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 enable enable AWS.Lambda.Powertools.Parameters.Tests diff --git a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj index 57314fc65..ce7a88ba5 100644 --- a/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj +++ b/libraries/tests/AWS.Lambda.Powertools.Tracing.Tests/AWS.Lambda.Powertools.Tracing.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 default AWS.Lambda.Powertools.Tracing.Tests AWS.Lambda.Powertools.Tracing.Tests diff --git a/libraries/tests/Directory.Build.props b/libraries/tests/Directory.Build.props index b320c91fd..e714cb16b 100644 --- a/libraries/tests/Directory.Build.props +++ b/libraries/tests/Directory.Build.props @@ -1,4 +1,7 @@ + + net6.0;net8.0 + diff --git a/poetry.lock b/poetry.lock index 40b30317f..259e15ae4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "click" @@ -58,20 +58,20 @@ smmap = ">=3.0.1,<6" [[package]] name = "gitpython" -version = "3.1.37" +version = "3.1.41" description = "GitPython is a Python library used to interact with Git repositories" optional = false python-versions = ">=3.7" files = [ - {file = "GitPython-3.1.37-py3-none-any.whl", hash = "sha256:5f4c4187de49616d710a77e98ddf17b4782060a1788df441846bddefbb89ab33"}, - {file = "GitPython-3.1.37.tar.gz", hash = "sha256:f9b9ddc0761c125d5780eab2d64be4873fc6817c2899cbcb34b02344bdc7bc54"}, + {file = "GitPython-3.1.41-py3-none-any.whl", hash = "sha256:c36b6634d069b3f719610175020a9aed919421c87552185b085e04fbbdb10b7c"}, + {file = "GitPython-3.1.41.tar.gz", hash = "sha256:ed66e624884f76df22c8e16066d567aaa5a37d5b5fa19db2c6df6f7156db9048"}, ] [package.dependencies] gitdb = ">=4.0.1,<5" [package.extras] -test = ["black", "coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mypy", "pre-commit", "pytest", "pytest-cov", "pytest-sugar"] +test = ["black", "coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock", "mypy", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "sumtypes"] [[package]] name = "importlib-metadata" @@ -94,13 +94,13 @@ testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packag [[package]] name = "jinja2" -version = "3.1.2" +version = "3.1.3" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ - {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, - {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, + {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, + {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, ] [package.dependencies]