我有这样的 SQSClient 设置:
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
我一定做错了什么,但我没有看到。