2017-08-04 81 views
0

我有这样的一个SQSClient设置:AWS的X射线“实体不存在CallContext中”使用.NET控制台应用程序

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

当我在客户端调用

var receiveResult = _amazonSqs.ReceiveMessage(_longPollRequest); 

我得到以下异常

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() 

我曾尝试添加类似AWSXRayRecorder.Instance.BeginSegment();,但不知何故,需要一个traceId,我似乎无法满足

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

例外:

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 

我必须做一些错误,但我没有看到它。

+0

试着问自己的官方论坛的问题。亚马逊家伙对此非常敏感。 https://forums.aws.amazon.com/forum.jspa?forumID=241&start=0 – Ruslan

+1

我试过了:https://forums.aws.amazon.com/thread.jspa?threadID=261162但我没有得到同样的反应,你有我想:) – LordSauron

回答

3

您可以使用TraceId.NewId();创建新的跟踪ID。这个类在Amazon.XRay.Recorder.Core.Internal.Entities命名空间中可用。

正如Ruslan所说,我们(AWS X-Ray团队)在AWS X-Ray官方论坛上非常活跃。不幸的是,您的链接帖子似乎已发布在AWS .NET语言特定论坛中。如果他们对X-Ray specific forum进行了更改,我们更有可能快速响应未来的帖子。

感谢,

詹姆斯B.

+0

非常感谢你,地狱是如何,我应该找到:) – LordSauron

+1

没问题。我已经提交了一个请求来暴露.NET SDK中的'Internal'命名空间[API参考](http://docs.aws.amazon.com/xray-sdk-for-dotnet/latest/reference/html/N_Amazon_XRay_Recorder_Core热媒)。 –

+0

对于我们来说,如果你只是自动为'''TraceId.NewId();'''执行一个超载,那么它看起来可以在node.js版本中工作呢? – LordSauron

相关问题