我很难弄清楚如何正确设置AWS X-Ray代理的dockerized ' Spring boot ';应用程序。
我正在AWS ECS (Fargate)上部署这个应用程序,并且与应用程序的主容器一起有X-Ray守护进程" AWS - otel_collector "它应该监听UDP端口2000。
我正在使用"发现"代理在应用程序资源中使用以下配置JSON文件。
{
"serviceName": "XRayInstrumentedService",
"contextMissingStrategy": "LOG_ERROR",
"daemonAddress": "127.0.0.1:2000",
"tracingEnabled": true,
"samplingStrategy": "CENTRAL",
"traceIdInjectionPrefix": "prefix",
"awsSdkVersion": 2,
"maxStackTraceLength": 50,
"streamingThreshold": 100,
"traceIdInjection": true,
"pluginsEnabled": true,
"collectSqlQueries": false
}
这是我的Dockerfile:
FROM amazoncorretto:11
ADD target/*.jar application.jar
ADD xray-agent/disco/disco-java-agent.jar /opt/xray-agent/disco/disco-java-agent.jar
ADD xray-agent/disco/disco-plugins/aws-xray-agent-plugin.jar /opt/xray-agent/disco/disco-plugins/aws-xray-agent-plugin.jar
ADD xray-agent/disco/disco-plugins/disco-java-agent-aws-plugin.jar /opt/xray-agent/disco/disco-plugins/disco-java-agent-aws-plugin.jar
ADD xray-agent/disco/disco-plugins/disco-java-agent-sql-plugin.jar /opt/xray-agent/disco/disco-plugins/disco-java-agent-sql-plugin.jar
ADD xray-agent/disco/disco-plugins/disco-java-agent-web-plugin.jar /opt/xray-agent/disco/disco-plugins/disco-java-agent-web-plugin.jar
ENV AWS_XRAY_TRACING_NAME=myapp
ENV JAVA_TOOL_OPTIONS=-javaagent:/opt/xray-agent/disco/disco-java-agent.jar=pluginPath=/opt/xray-agent/disco/disco-plugins
CMD ["java", "-Djava.security.egd=file:/dev/./urandom", "-Xms512m", "-Xmx1g", "-jar", "application.jar"]
当ECS任务启动时,我总是得到相同的错误:
c.a.x.s.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) ~[aws-xray-agent-plugin.jar:na]
at com.amazonaws.xray.internal.UnsignedXrayClient.getSamplingRules(UnsignedXrayClient.java:112) ~[aws-xray-agent-plugin.jar:na]
at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.pollRule(RulePoller.java:100) ~[aws-xray-agent-plugin.jar:na]
at com.amazonaws.xray.strategy.sampling.pollers.RulePoller.lambda$start$0(RulePoller.java:72) ~[aws-xray-agent-plugin.jar:na]
X-Ray daemon作为sidecar容器运行良好。
我不知道这里到底出了什么问题。
最后,我使用aws- openelement -agent解决了问题,而不是在"discover"上实现的aws-x -java-agent。图书馆