You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/tracing.md
+87-14
Original file line number
Diff line number
Diff line change
@@ -244,7 +244,7 @@ under a subsegment, or you are doing multithreaded programming. Refer examples b
244
244
}
245
245
```
246
246
247
-
## Instrumenting SDK clients and HTTP calls
247
+
## Instrumenting SDK clients
248
248
249
249
You should make sure to instrument the SDK clients explicitly based on the function dependency. You can instrument all of your AWS SDK for .NET clients by calling RegisterForAllServices before you create them.
250
250
@@ -277,25 +277,98 @@ To instrument clients for some services and not others, call Register instead of
277
277
Tracing.Register<IAmazonDynamoDB>()
278
278
```
279
279
280
-
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).
280
+
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)
281
+
282
+
## Instrumenting outgoing HTTP calls
283
+
284
+
=== "Function.cs"
285
+
286
+
```c# hl_lines="7"
287
+
using Amazon.XRay.Recorder.Handlers.System.Net;
288
+
289
+
public class Function
290
+
{
291
+
public Function()
292
+
{
293
+
var httpClient = new HttpClient(new HttpClientXRayTracingHandler(new HttpClientHandler()));
294
+
var myIp = await httpClient.GetStringAsync("https://checkip.amazonaws.com/");
295
+
}
296
+
}
297
+
```
298
+
299
+
More information about instrumenting [outgoing http calls](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet-httpclients.html).
281
300
282
301
## AOT Support
283
302
284
303
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
304
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
305
288
-
For the Tracing utility to work correctly and without trim warnings please add the following to your `.csproj` file
To use Tracing utility with AOT support you first need to add `WithTracing()` to the source generator you are using either the default `SourceGeneratorLambdaJsonSerializer`
309
+
or the Powertools Logging utility [source generator](logging.md#aot-support){:target="_blank"} `PowertoolsSourceGeneratorSerializer`.
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.
368
+
369
+
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.
298
370
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.
371
+
### Not supported
300
372
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.
373
+
!!! warning "Not supported"
374
+
Currently instrumenting SDK clients with `Tracing.RegisterForAllServices()` is not supported on AOT mode.
0 commit comments