问题
We currently have an internal library that we're using to make a lot of our HTTP calls that uses RestSharp rather that the HttpClient to make all of our requests to downstream services. Is it possible to enable x-ray tracing in AWS without re-writing that library to instead use HttpClient? The goal is to get the same functionality that would be outlined here (when using HttpClient): https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet-httpclients.html
回答1:
The RestSharp library is a separate HTTP client which the X-Ray SDK for .NET does not support at this time. I'm not familiar with RestSharp, but I believe it uses HttpClient under the hood as that is the native library for HTTP calls in .NET. So if you could somehow replace the underlying HttpClient used by the RestSharp library with an instrumented version of HttpClient, that would enable X-Ray tracing, but I'm not sure if such a replacement is possible.
The X-Ray SDK for .NET is open sourced, and we're happy to take pull requests if you'd like to write a module for X-Ray RestSharp support https://github.com/aws/aws-xray-sdk-dotnet
来源:https://stackoverflow.com/questions/63523096/possible-to-enable-x-ray-tracing-with-restsharp