【以下的问题经过翻译处理】 我试图将AWS X-Ray添加到我们的解决方案中,包括S3、Lambda和DynamoDB服务,但我在处理异常"Entity doesn't exist in callcontext"方面遇到了困难。
通常情况下,我需要在通过WCF Web服务文件(.svc)启动的库项目中使用X-Ray服务,但为了解决问题,我在一个简单的控制台应用程序中尝试了以下最小示例代码,并且出现了完全相同的错误:
private static void Main(string[] args)
{
AWSSDKHandler.RegisterXRayForAllServices();
var lambdaClient = new AmazonLambdaClient(awsCredentials, regionEndpoint);
lambdaClient.Invoke(new InvokeRequest { ... });
}
当禁用RegisterXRayForAllServices
行时,Lambda请求可以正常工作,但当启用该行时,在调用Lambda请求时会引发以下异常:
at Amazon.XRay.Recorder.Core.Internal.Context.CallContextContainer.GetEntity()
at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.ProcessBeginRequest(IExecutionContext executionContext)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.ProcessBeginRequest(IExecutionContext executionContext)
at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.InvokeSync(IExecutionContext executionContext)
at Amazon.Runtime.Internal.CallbackHandler.InvokeSync(IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\CallbackHandler.cs:line 46
at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeSync(IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\ErrorCallbackHandler.cs:line 44
at Amazon.Runtime.Internal.MetricsHandler.InvokeSync(IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\MetricsHandler.cs:line 40
at Amazon.Runtime.Internal.RuntimePipeline.InvokeSync(IExecutionContext executionContext) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\RuntimePipeline.cs:line 136
at Amazon.Runtime.AmazonServiceClient.Invoke[TResponse](AmazonWebServiceRequest request, InvokeOptionsBase options) in D:\JenkinsWorkspaces\trebuchet-stage-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\AmazonServiceClient.cs:line 206
at Program.Main(String[] args) in Program.cs:line 42
使用中的版本
.Net Framework 4.7.2
Nuget AWSDDK.Lambda 3.7.13.16
Nuget AWSXRayRecoder: 2.10.1
在其他不涉及AWS服务的项目中,我没有在RegisterXRay(this, "Program")
和为WCF服务添加分段和自定义端点行为时出现问题,但在这里,我需要一些帮助,如何正确设置XRay recorder以用于AWS服务。在App.config/Web.config中是否需要额外的配置?