How to capture requests/responses made from RestSharp in AWS XRay service

210 Views Asked by At

I am using the RestSharp library for making requests to web apis.

https://www.nuget.org/packages/RestSharp

I use AWS XRay and would like to ensure that requests/responses are captured in the XRay service as well. How exactly can I enable this? Is there an extension method I can use?

What changes need to happen to aws-xray-sdk-dotnet such that someone can create a PR and add this functionality if its not already there?

1

There are 1 best solutions below

0
On

This seems to be a duplicate of: Possible to enable X-Ray tracing with RestSharp

As mentioned in that question's comments, you can instrument the underlying HttpClient of a RestSharp client with the aspect-oriented Diagnostic Listener in .NET. The X-Ray auto-instrumentation agent for .NET (in beta) uses just that approach and should be able to instrument your client automatically, no need for manual wrapping. Getting started instructions are in the README: https://github.com/aws/aws-xray-dotnet-agent