Skip to content

fix: Resolve Lambda auto-instrumentation race condition#3508

Merged
tippmar-nr merged 9 commits intomainfrom
fix/lambda-auto-instrumentation-race-condition
Apr 2, 2026
Merged

fix: Resolve Lambda auto-instrumentation race condition#3508
tippmar-nr merged 9 commits intomainfrom
fix/lambda-auto-instrumentation-race-condition

Conversation

@tippmar-nr
Copy link
Copy Markdown
Member

@tippmar-nr tippmar-nr commented Mar 27, 2026

Summary

  • Adds EnsureTransformCompletesWrapper that wraps the Lambda bootstrap handler to create transactions early and ensure they complete before the runtime sends a response, fixing an async race condition where payloads could be lost
  • Moves transaction creation/ending responsibility from HandlerMethodWrapper to the new wrapper; HandlerMethodWrapper now only sets the transaction name on the existing transaction
  • Adds net10.0 TFM support with version-specific Amazon.Lambda.RuntimeSupport packages
  • Adds CoreLatest test fixtures to ensure different versions of Amazon.Lambda.RuntimeSupport are tested
  • Updates Dotty to include Amazon.Lambda.RuntimeSupport in the list of packages it updates.

Fixes #3473

…sponse

Wrap the Lambda bootstrap handler to create the transaction early and
ensure it completes before the runtime sends a response. This prevents
a race condition where async continuations could run out of order,
causing the Lambda runtime to return before the agent generates a
payload.

Also fixes duplicate "Test" in auto-instrumentation test class names,
adds net10.0 TFM support with version-specific RuntimeSupport packages,
and fixes a missing comma in Dotty packageInfo.json.
@tippmar-nr tippmar-nr changed the title fix: resolve Lambda auto-instrumentation race condition fix: Resolve Lambda auto-instrumentation race condition Mar 27, 2026
Multi-TFM Web SDK projects fail MSBuild solution-level DeployOnBuild
with NETSDK1129. The CI pre-publish step already handles per-TFM
publishing correctly.
DeployOnBuild=false in the csproj is overridden by the command-line
-p:DeployOnBuild=true. IsPublishable=false prevents the Publish target
from running regardless of command-line properties.
Microsoft.NET.Sdk.Web hooks into the Build target via DeployOnBuild,
which fails for multi-TFM projects (NETSDK1129). Command-line
properties cannot be overridden by the project file.

Switch to Microsoft.NET.Sdk with an explicit FrameworkReference to
Microsoft.AspNetCore.App and add a GlobalUsings.cs for the implicit
usings that Web SDK previously provided.
…ption

The AwsLambda wrapper now depends on Amazon.Lambda.RuntimeSupport, which
is not present in non-Lambda applications. Add all three AwsLambda
wrapper names to the dynamic load list so the assembly is only loaded
when running in a Lambda environment.
@tippmar-nr tippmar-nr marked this pull request as ready for review March 30, 2026 19:53
@tippmar-nr tippmar-nr requested a review from a team as a code owner March 30, 2026 19:53
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.79%. Comparing base (73de305) to head (c7e2c0a).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3508      +/-   ##
==========================================
- Coverage   81.82%   81.79%   -0.03%     
==========================================
  Files         508      508              
  Lines       34220    34220              
  Branches     4040     4040              
==========================================
- Hits        27999    27990       -9     
- Misses       5254     5265      +11     
+ Partials      967      965       -2     
Flag Coverage Δ
Agent 82.78% <ø> (-0.03%) ⬇️
Profiler 71.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../NewRelic/Agent/Core/Utilities/ExtensionsLoader.cs 32.87% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tippmar-nr tippmar-nr merged commit 25c59e7 into main Apr 2, 2026
214 of 216 checks passed
@tippmar-nr tippmar-nr deleted the fix/lambda-auto-instrumentation-race-condition branch April 2, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some async lambdas do not generate a serverless payload consistently

3 participants