简体   繁体   English

Aws XRay .net控制台应用程序中的“实体在CallContext中不存在”

[英]Aws XRay “Entity doesn't exist in CallContext” in .net console application

I have a setup for SQSClient like this: 我有一个像这样的SQSClient设置:

var client = new AmazonSQSClient();
new AWSSdkTracingHandler(AWSXRayRecorder.Instance).AddEventHandler(client);
return client;

now when i call the client 现在我打电话给客户

var receiveResult = _amazonSqs.ReceiveMessage(_longPollRequest);

I get the following exception 我得到以下异常

Amazon.XRay.Recorder.Core.Exceptions.EntityNotAvailableException was 
unhandled by user code
HResult=-2146233088
Message=Entity doesn't exist in CallContext
Source=AWSXRayRecorder.Core
StackTrace:
   at Amazon.XRay.Recorder.Core.Internal.Utils.TraceContext.GetEntity() in c:\Jenkins\jobs\net-release\workspace\sdk\src\Core\Internal\Utils\TraceContext.cs:line 47
   at Amazon.XRay.Recorder.Handlers.AwsSdk.AWSSdkTracingHandler.ExceptionEventHandler(Object sender, ExceptionEventArgs e) in c:\Jenkins\jobs\net-release\workspace\sdk\src\Handlers\AwsSdk\AWSSdkTracingHandler.cs:line 324
   at Amazon.Runtime.AmazonServiceClient.ProcessExceptionHandlers(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorCallbackHandler.HandleException(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.PipelineHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.MetricsHandler.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.Internal.RuntimePipeline.InvokeSync(IExecutionContext executionContext)
   at Amazon.Runtime.AmazonServiceClient.Invoke[TRequest,TResponse](TRequest request, IMarshaller`2 marshaller, ResponseUnmarshaller unmarshaller)
   at Amazon.SQS.AmazonSQSClient.ReceiveMessage(ReceiveMessageRequest request)
   at BasePriceCalculator.Library.Services.AwsSqsCalculationMessageListener.Listen() in C:\working\base-price-calculator\BasePriceCalculator.Library\Services\AwsSqsCalculationMessageListener.cs:line 74
   at BasePriceCalculator.BasePriceCalculatorService.<Start>b__3_0() in C:\working\base-price-calculator\BasePriceCalculator\BasePriceCalculatorService.cs:line 26
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

i have tried adding something like AWSXRayRecorder.Instance.BeginSegment(); 我尝试过添加像AWSXRayRecorder.Instance.BeginSegment(); but somehow that requires a traceId that i can't seem to satisfy 但不知何故,这需要一个我似乎无法满足的traceId

AWSXRayRecorder.Instance.BeginSegment("ReceiveMessage", Guid.NewGuid().ToString());
var receiveResult = _amazonSqs.ReceiveMessage(_longPollRequest);
AWSXRayRecorder.Instance.EndSegment();

exception: 例外:

System.ArgumentException was unhandled by user code
HResult=-2147024809
Message=Trace id is invalid.
Parameter name: value
ParamName=value
Source=AWSXRayRecorder.Core
StackTrace:
   at Amazon.XRay.Recorder.Core.Internal.Entities.Entity.set_TraceId(String value) in c:\Jenkins\jobs\net-release\workspace\sdk\src\Core\Internal\Entities\Entity.cs:line 78
   at Amazon.XRay.Recorder.Core.Internal.Entities.Segment..ctor(String name, String traceId, String parentId) in c:\Jenkins\jobs\net-release\workspace\sdk\src\Core\Internal\Entities\Segment.cs:line 46
   at Amazon.XRay.Recorder.Core.AWSXRayRecorder.BeginSegment(String name, String traceId, String parentId, SampleDecision sampleDecision) in c:\Jenkins\jobs\net-release\workspace\sdk\src\Core\AWSXRayRecorder.cs:line 164
   at BasePriceCalculator.Library.Services.AwsSqsCalculationMessageListener.<Listen>b__10_1() in C:\working\base-price-calculator\BasePriceCalculator.Library\Services\AwsSqsCalculationMessageListener.cs:line 65
   at StatsdClient.DogStatsdService.Time[T](Func`1 func, String statName, Double sampleRate, String[] tags)
   at StatsdClient.DogStatsd.Time[T](Func`1 func, String statName, Double sampleRate, String[] tags)
   at DataDogUtils.DataDogMetricPublisher.Time[T](Func`1 func, String statName, Double sampleRate, String[] tags)
   at BasePriceCalculator.Library.Services.AwsSqsCalculationMessageListener.<Listen>b__10_0() in C:\working\base-price-calculator\BasePriceCalculator.Library\Services\AwsSqsCalculationMessageListener.cs:line 63
   at Polly.Policy`1.<>c__DisplayClass67_0.<ExecuteAndCapture>b__0(Context ctx, CancellationToken ct) in C:\projects\polly\src\Polly.Shared\Policy.TResult.cs:line 194
   at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, IEnumerable`1 shouldRetryExceptionPredicates, IEnumerable`1 shouldRetryResultPredicates, Func`1 policyStateFactory) in C:\projects\polly\src\Polly.Shared\Retry\RetryEngine.cs:line 26

I must be doing something wrong, but i am not seeing it. 我一定是做错了,但我没有看到。

You can create a new Trace ID using TraceId.NewId(); 您可以使用TraceId.NewId();创建新的跟踪ID TraceId.NewId(); . This class is available in the Amazon.XRay.Recorder.Core.Internal.Entities namespace. 此类在Amazon.XRay.Recorder.Core.Internal.Entities命名空间中可用。

As Ruslan mentioned, we (the AWS X-Ray team) are very active on the AWS X-Ray official forum. 正如Ruslan所说,我们(AWS X-Ray团队)在AWS X-Ray官方论坛上非常活跃。 Unfortunately, your linked post appears to have been posted in the AWS .NET language specific forum. 不幸的是,您的链接帖子似乎已发布在AWS .NET语言特定论坛中。 We're much more likely to quickly respond to future posts if they're made to the X-Ray specific forum . 如果将它们发布到X-Ray特定论坛,我们更有可能快速回复未来的帖子。

Thanks, 谢谢,

James B. 詹姆斯B.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM