Hello,
I'm using the aws-xray-sdk-core: 3.0.0 and when I turn it on on production, I sometimes have the following error.
TypeError: Cannot read property 'forEach' of undefined
at assembleTargets (/app/node_modules/aws-xray-sdk-core/lib/middleware/sampling/service_connector.js line 147 col 7)
docs.forEach(function(doc) {
at IncomingMessage.res.on (/app/node_modules/aws-xray-sdk-core/lib/middleware/sampling/service_connector.js line 82 col 29)
var targetsMapping = assembleTargets(dataObj);
at IncomingMessage.emit (events.js line 203 col 14)
at IncomingMessage.EventEmitter.emit (domain.js line 448 col 19)
at endReadableNT (_stream_readable.js line 1145 col 11)
at process._tickCallback (internal/process/next_tick.js line 63 col 18)
Looks like there is an issue between the SDK and the daemon, but not sure where exactly.
One thing to know is that I've set all my rules to Limit to聽0 r/sec, then聽0%聽fixed rate
Hmmm you appear to be getting an invalid response from the X-Ray service. The SDK polls the service roughly every ten seconds using the GetSamplingTargets API to ensure the SDK is performing sampling at an appropriate rate. The error you're getting seems to imply there is no SamplingTargetDocuments in the response.
How often are you receiving this error? If it's rare, then it's probably just an issue with the response occasionally getting jumbled over the network and we should be able to resolve this by doing better validation of the response.
I turned it on on production for one day and received this error 7 times for 8 containers. So I guess it's rare enough.
What's worrying me is that I'm the only one reporting it, there is probably something wrong with my network as well.
Relative to the frequency of the polling that is fairly rare. To confirm, the sampling rate you set is being read correctly right? Like you've seen no segments being emitted to the X-Ray console as you'd expect with your sampling rate?
Yes, the sampling rate I set is being read correctly.
I've got few health checks from time to time like two every 6 hours or so, but my guess is that it's when the application boots it doesn't have fresh data and work from the local sampling rate, which is the default one and expected.
Ok, we'll get a fix out as soon as we can so it's not disrupting your application!
Fix released in 3.0.1!
Thanks @willarmiros
Most helpful comment
Fix released in 3.0.1!