Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .autover/changes/45c6fa93-45cc-402a-869c-41dbcec2c799.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "Amazon.Lambda.RuntimeSupport",
"Type": "Patch",
"ChangelogMessages": [
"Fix thread pool starvation under multi-concurrency"
]
}
]
}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## Release 2026-05-18

### Amazon.Lambda.Core (3.1.0)
* [Preview] Add LambdaLogger.ConfigureStructuredLogging to customize the JsonSerializerOptions used for serializing logging parameters.
* Add preview ILambdaSerializer Serializer property to ILambdaContext (default-implemented to null on net8.0+) so user code can access the serializer registered with the runtime. Marked [Experimental("AWSLAMBDA001")]; class-library mode requires an updated managed Lambda runtime to populate this property. The Experimental flag will be removed in a follow-up release once the managed runtime is deployed.
### Amazon.Lambda.RuntimeSupport (2.1.0)
* Add support for handling the structured logging customization from Amazon.Lambda.Core.
* Propagate the registered ILambdaSerializer to the per-invocation ILambdaContext.Serializer. Surfaces the new preview ILambdaContext.Serializer (AWSLAMBDA001); the Experimental flag will be removed in a follow-up release once the managed runtime is deployed.
### Amazon.Lambda.Annotations (2.0.1)
* Fix CS0121 ambiguity error in generated Program.g.cs when a Lambda handler has no input parameters and returns Task. The source generator now uses the unambiguous LambdaBootstrapBuilder.Create(Func<Stream, Task>) overload for this case.
### Amazon.Lambda.TestUtilities (4.1.0)
* Add Serializer setter to TestLambdaContext to mirror the new preview ILambdaContext.Serializer property. Marked [Experimental("AWSLAMBDA001")]; the Experimental flag will be removed in a follow-up release once the managed runtime is deployed.
### Amazon.Lambda.AspNetCoreServer (10.1.1)
* Fix InvokeFeatures.Set<TFeature> to bump the feature collection revision so middleware that wraps the response body (e.g. OutputCache, ResponseCompression) is properly visible to ASP.NET Core's FeatureReferences cache. Resolves https://github.com/aws/aws-lambda-dotnet/issues/1702 where IOutputCache stored empty response bodies.

## Release 2026-05-15

### Amazon.Lambda.AspNetCoreServer (10.1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IncludeBuildOutput>false</IncludeBuildOutput>

<Version>2.0.0</Version>
<Version>2.0.1</Version>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,64 @@ public static async Task Main(string[] args)

#line 45 "C:\codebase\V3\HLL\aws-lambda-dotnet\Libraries\src\Amazon.Lambda.Annotations.SourceGenerator\Templates\ExecutableAssembly.tt"

}
else if (!model.GeneratedMethod.Parameters.Any() && model.LambdaMethod.ReturnsVoidTask)
{


#line default
#line hidden
this.Write(" Func<Stream, System.Threading.Tasks.Task> ");

#line default
#line hidden
this.Write(this.ToStringHelper.ToStringWithCulture(model.LambdaMethod.ExecutableAssemblyHandlerName));

#line default
#line hidden
this.Write(" = new ");

#line default
#line hidden
this.Write(this.ToStringHelper.ToStringWithCulture(model.LambdaMethod.ContainingNamespace));

#line default
#line hidden
this.Write(".");

#line default
#line hidden
this.Write(this.ToStringHelper.ToStringWithCulture(model.LambdaMethod.ContainingType.Name));

#line default
#line hidden
this.Write("_");

#line default
#line hidden
this.Write(this.ToStringHelper.ToStringWithCulture(model.LambdaMethod.Name));

#line default
#line hidden
this.Write("_Generated().");

#line default
#line hidden
this.Write(this.ToStringHelper.ToStringWithCulture(model.LambdaMethod.Name));

#line default
#line hidden
this.Write(";\r\n await Amazon.Lambda.RuntimeSupport.LambdaBootstrapBuilder.Crea" +
"te(");

#line default
#line hidden
this.Write(this.ToStringHelper.ToStringWithCulture(model.LambdaMethod.ExecutableAssemblyHandlerName));

#line default
#line hidden
this.Write(").Build().RunAsync();\r\n break;\r\n");

}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public class GeneratedProgram
await Amazon.Lambda.RuntimeSupport.LambdaBootstrapBuilder.Create(<#= model.LambdaMethod.ExecutableAssemblyHandlerName #>, new <#= this._lambdaFunctions[0].SerializerInfo.SerializerName #>()).Build().RunAsync();
break;
<#
}
else if (!model.GeneratedMethod.Parameters.Any() && model.LambdaMethod.ReturnsVoidTask)
{
// No typed input and Task return: Func<Stream, Task> is ambiguous between
// Create<TInput>(Func<TInput, Task>, ILambdaSerializer) and
// Create<TOutput>(Func<Stream, TOutput>, ILambdaSerializer).
// Use the non-generic, non-serializer overload to resolve CS0121.
#>
Func<Stream, System.Threading.Tasks.Task> <#= model.LambdaMethod.ExecutableAssemblyHandlerName #> = new <#= model.LambdaMethod.ContainingNamespace #>.<#= model.LambdaMethod.ContainingType.Name #>_<#= model.LambdaMethod.Name #>_Generated().<#= model.LambdaMethod.Name #>;
await Amazon.Lambda.RuntimeSupport.LambdaBootstrapBuilder.Create(<#= model.LambdaMethod.ExecutableAssemblyHandlerName #>).Build().RunAsync();
break;
<#
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<AssemblyOriginatorKeyFile>..\..\..\buildtools\public.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>

<Version>2.0.0</Version>
<Version>2.0.1</Version>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Description>Amazon.Lambda.AspNetCoreServer makes it easy to run ASP.NET Core Web API applications as AWS Lambda functions.</Description>
<TargetFrameworks>$(DefaultPackageTargets)</TargetFrameworks>
<AssemblyTitle>Amazon.Lambda.AspNetCoreServer</AssemblyTitle>
<Version>10.1.0</Version>
<Version>10.1.1</Version>
<AssemblyName>Amazon.Lambda.AspNetCoreServer</AssemblyName>
<PackageId>Amazon.Lambda.AspNetCoreServer</PackageId>
<PackageTags>AWS;Amazon;Lambda;aspnetcore</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ public IEnumerator<KeyValuePair<Type, object>> GetEnumerator()

public void Set<TFeature>(TFeature instance)
{
if (instance == null)
return;

_features[typeof(TFeature)] = instance;
// Delegate to the indexer so _containerRevision is bumped, otherwise
// ASP.NET Core's FeatureReferences cache will return stale feature
// references after middleware (e.g. OutputCache, ResponseCompression)
// wraps the response body via HttpContext.Response.Body = wrapper.
this[typeof(TFeature)] = instance;
}

IEnumerator IEnumerable.GetEnumerator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>netstandard2.0;$(DefaultPackageTargets)</TargetFrameworks>
<Description>Amazon Lambda .NET Core support - Core package.</Description>
<AssemblyTitle>Amazon.Lambda.Core</AssemblyTitle>
<Version>3.0.0</Version>
<Version>3.1.0</Version>
<AssemblyName>Amazon.Lambda.Core</AssemblyName>
<PackageId>Amazon.Lambda.Core</PackageId>
<PackageTags>AWS;Amazon;Lambda</PackageTags>
Expand Down
20 changes: 20 additions & 0 deletions Libraries/src/Amazon.Lambda.Core/ILambdaContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Amazon.Lambda.Core
{
using System;
using System.Diagnostics.CodeAnalysis;

/// <summary>
/// Object that allows you to access useful information available within
Expand Down Expand Up @@ -95,6 +96,25 @@ public interface ILambdaContext
/// The trace id generated by Lambda for distributed tracing across AWS services.
/// </summary>
string TraceId { get { return string.Empty; } }

/// <summary>
/// The <see cref="ILambdaSerializer"/> the Lambda function registered with the
/// runtime — either the instance passed to
/// <c>LambdaBootstrapBuilder.Create(handler, serializer)</c> /
/// <c>HandlerWrapper.GetHandlerWrapper(handler, serializer)</c>, or the type set
/// via <c>[assembly: LambdaSerializer(typeof(...))]</c> in class-library mode.
/// User code can reuse it for ad-hoc (de)serialization without re-instantiating.
/// Can be null when the function did not register a serializer (e.g., raw-stream
/// handlers).
/// </summary>
/// <remarks>
/// <para><b>Preview API.</b> Class-library mode requires an updated managed
/// Lambda runtime to populate this property; until that ships, the value will
/// be null when running in class-library mode. The <see cref="ExperimentalAttribute"/>
/// is applied to surface this caveat at the call site.</para>
/// </remarks>
[Experimental("AWSLAMBDA001")]
ILambdaSerializer Serializer { get { return null; } }
#endif
}
}
27 changes: 27 additions & 0 deletions Libraries/src/Amazon.Lambda.Core/LambdaLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,33 @@ public static void Log(string level, Exception exception, string message, params
/// <param name="message">Message to log. The message may have format arguments.</param>
/// <param name="args">Arguments to format the message with.</param>
public static void Log(LogLevel level, Exception exception, string message, params object[] args) => Log(level.ToString(), exception, message, args);

// This field must not be readonly because SetConfigureStructuredLoggingAction replaces the value
// when Amazon.Lambda.RuntimeSupport registers its structured logging callback.
private static Action<StructuredLoggingOptions> _configureStructuredLoggingAction = (options) => _placeHolderStructuredLoggingOptions = options;

// Because a user might call ConfigureStructuredLogging before the Lambda runtime has a chance to replace the _configureStructuredLoggingAction with the
// real implementation, we need to hold onto the options they provided until the Lambda runtime can use them to configure structured logging.
private static StructuredLoggingOptions _placeHolderStructuredLoggingOptions;

/// <summary>
/// When structured logging is enabled this method will allow overriding the default configuration the Lambda runtime uses for structured logging.
/// </summary>
/// <param name="options">The options to use for configuring structured logging.</param>
[RequiresPreviewFeatures("This method is in preview until the latest changes of the .NET Lambda runtime client have been deployed to the Lambda managed runtimes")]
public static void ConfigureStructuredLogging(StructuredLoggingOptions options) => _configureStructuredLoggingAction(options);

internal static void SetConfigureStructuredLoggingAction(Action<StructuredLoggingOptions> configureStructuredLoggingAction)
{
_configureStructuredLoggingAction = configureStructuredLoggingAction;

// If a user set the structured logging options before the Lambda runtime set the real _configureStructuredLoggingAction,
// we need to call it now to make sure the user's options are applied.
if (_placeHolderStructuredLoggingOptions != null)
{
_configureStructuredLoggingAction(_placeHolderStructuredLoggingOptions);
}
}
#endif
}
}
18 changes: 18 additions & 0 deletions Libraries/src/Amazon.Lambda.Core/StructuredLoggingOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#if NET8_0_OR_GREATER
using System.Text.Json;

namespace Amazon.Lambda.Core;

/// <summary>
/// The options that can be overridden for structured logging.
/// </summary>
public class StructuredLoggingOptions
{
/// <summary>
/// Override the default JsonSerializerOptions used by the Lambda runtime for serializing object parameters in structured logs.
/// </summary>
public JsonSerializerOptions OverrideSerializerOptions { get; set; }
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<Version>2.0.0</Version>
<Version>2.1.0</Version>
<Description>Provides a bootstrap and Lambda Runtime API Client to help you to develop custom .NET Core Lambda Runtimes.</Description>
<AssemblyTitle>Amazon.Lambda.RuntimeSupport</AssemblyTitle>
<PackageId>Amazon.Lambda.RuntimeSupport</PackageId>
Expand Down
Loading
Loading