Skip to content

Commit aef100c

Browse files
authored
Merge pull request #607 from hjgraca/aot-tracing-support
chore: Tracing add AOT support
2 parents eef0ea8 + 5f2b82a commit aef100c

File tree

11 files changed

+823
-697
lines changed

11 files changed

+823
-697
lines changed

docs/core/tracing.md

+21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ a provides functionality to reduce the overhead of performing common tracing tas
1616
* Better experience when developing with multiple threads.
1717
* Auto-patch supported modules by AWS X-Ray
1818
* Auto-disable when not running in AWS Lambda environment
19+
* Ahead-of-Time compilation to native code support [AOT](https://docs.aws.amazon.com/lambda/latest/dg/dotnet-native-aot.html) from version 1.5.0
1920

2021
## Installation
2122

@@ -278,3 +279,23 @@ Tracing.Register<IAmazonDynamoDB>()
278279

279280
This functionality is a thin wrapper for AWS X-Ray .NET SDK. Refer details on [how to instrument SDK client with Xray](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet-sdkclients.html) and [outgoing http calls](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet-httpclients.html).
280281

282+
## AOT Support
283+
284+
Native AOT trims your application code as part of the compilation to ensure that the binary is as small as possible. .NET 8 for Lambda provides improved trimming support compared to previous versions of .NET.
285+
286+
These improvements offer the potential to eliminate build-time trimming warnings, but .NET will never be completely trim safe. This means that parts of libraries that your function relies on may be trimmed out as part of the compilation step. You can manage this by defining TrimmerRootAssemblies as part of your `.csproj` file as shown in the following example.
287+
288+
For the Tracing utility to work correctly and without trim warnings please add the following to your `.csproj` file
289+
290+
```xaml
291+
<ItemGroup>
292+
<TrimmerRootAssembly Include="AWSSDK.Core" />
293+
<TrimmerRootAssembly Include="AWSXRayRecorder.Core" />
294+
<TrimmerRootAssembly Include="AWSXRayRecorder.Handlers.AwsSdk" />
295+
<TrimmerRootAssembly Include="Amazon.Lambda.APIGatewayEvents" />
296+
</ItemGroup>
297+
```
298+
299+
Note that when you receive a trim warning, adding the class that generates the warning to TrimmerRootAssembly might not resolve the issue. A trim warning indicates that the class is trying to access some other class that can't be determined until runtime. To avoid runtime errors, add this second class to TrimmerRootAssembly.
300+
301+
To learn more about managing trim warnings, see [Introduction to trim warnings](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/fixing-warnings) in the Microsoft .NET documentation.

0 commit comments

Comments
 (0)