1

I'm having difficulty figuring out how to properly set up the AWS X-Ray Agent for a dockerized "Spring Boot" application.

I'm deploying this application on AWS ECS (Fargate) and together with the main container with the application there is the X-Ray daemon "aws-otel-collector" which should be listening on UDP port 2000.

I'm using the "Disco" Agent with the following configuration JSON file in the application resources.

{
    "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
}

This is my 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"]

When the ECS Task starts I always get the same error:

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]

the X-Ray deamon seems running fine as a sidecar container.

I'm confused about what's the exact problem here.

HK15
  • 47
  • 9
  • Hard to tell what exactly is going on. Out of interest, did you have a look at our native OpenTelemetry support in ECS (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/trace-data.html)? – Michael Hausenblas Apr 05 '23 at 09:38
  • 1
    @MichaelHausenblas Thank you. In the end I solved using the aws-opentelemetry-agent instead of the aws-xray-java-agent implemented on the "Disco" Library. – HK15 Apr 05 '23 at 10:57
  • Excellent! I'd recommend to answer your own question here, below so that others can also benefit from your insight. – Michael Hausenblas Apr 05 '23 at 13:09

1 Answers1

1

In the end I solved using the aws-opentelemetry-agent instead of the aws-xray-java-agent implemented on the "Disco" Library

HK15
  • 47
  • 9