I am working on springboot & AWS X-Ray integration, as part of this we pushed our code and deployed springboot app and x-ray deamon as a sidecar container in ESC Fargate task on production environmenet and everything works fine, however we dont need any x-ray support for lower environmenets like QA and STAGE so we are not deploying x-ray deamon; beacuse of that the existing code is not able to connect to x-ray deamon and throwing below exception.
04:54:12.364 [pool-2-thread-1] ERROR com.amazonaws.xray.strategy.sampling.pollers.RulePoller -Encountered error polling GetSamplingRules:
com.amazonaws.xray.internal.XrayClientException: Could not serialize and send request.
at com.amazonaws.xray.internal.UnsignedXrayClient.sendRequest(UnsignedXrayClient.java:142) ~[core-commons-qa2-1.0.0.jar!/:?]
at com.amazonaws.xray.internal.UnsignedXrayClient.getSamplingRules(UnsignedXrayClient.java:112) ~[core-commons-qa2-1.0.0.jar!/:?]
at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.pollRule(RulePoller.java:100) ~[core-commons-qa2-1.0.0.jar!/:?]
at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.lambda$start$0(RulePoller.java:72) ~[core-commons-qa2-1.0.0.jar!/:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[?:?]
at java.net.Socket.connect(Socket.java:609) ~[?:?]
How do we handle this kind of scnario where we can successfuly run the same code base on lower environments without removing X-Ray SDK code ? Is there any configuration exists to check and instrument only if X-ray deamon is running ? please shed some light here.