Home > other >  ECS fargate doesn't show up in xray
ECS fargate doesn't show up in xray

Time:01-31

So I have a kinesis consumer that is running in ECS fargate that I am trying to add on x-ray. I have added the x-ray side car to my CloudFormation for the task definition, and it shows up in the task and is running

      {
        "name": "xray-daemon",
        "Image": {************.dkr.ecr.us-east-1.amazonaws.com/xray-daemon},
        "cpu": 32,
        "memoryReservation": 256,
        "portMappings" : [
          {
            "containerPort": 2000,
            "protocol": "udp"
          }
        ]
      },

I then put before and after an SNS publish

AWSXRay.beginSubsegment("SNS Publish")
-- do the publish
AWSXRay.endSubsegment();

And still no luck.

Finally, I added the following in the start of my app to, which I beleive, is logging the entire ECS process to x-ray

    AWSXRayRecorderBuilder builder = AWSXRayRecorderBuilder.standard().withPlugin(new ECSPlugin())
    AWSXRay.setGlobalRecorder(builder.build())

So far, everything runs fine (consumer is unaffected, and running fine) but nothing is showing up in x-ray. Any ideas on what I might be missing?

Thanks

CodePudding user response:

You need to wrap your kinesis consumer's code in a segment to be able to see any of the trace data. Segment will denote your consumer as a node in the X-Ray service map.

https://github.com/aws/aws-xray-sdk-java#applications-not-using-javaxservlet-may-include-custom-interceptors-to-begin-and-end-trace-segments

Use the AWSXRay.beginSegment and AWSXRay.endSegment APIs (similar to the subsegment APIs you're already using) to create a segment around the process. Subsegments require a segment to be present. You're probably getting x-ray ContextMissing errors in your log while trying to create subsegment.

CodePudding user response:

As you add this in your app:

   AWSXRayRecorderBuilder builder = AWSXRayRecorderBuilder.standard().withPlugin(new ECSPlugin())
    AWSXRay.setGlobalRecorder(builder.build())

I'm not expert on aws but, you didn't miss that?

Since Fargate is a service that manages the instances your tasks run on, access to the underlying host is prohibited. Consequently, the ECSPlugin and EC2Plugins for X-Ray will not work.

If not, take a look on code snippet how you can add x-ray sdk to your app and run x-ray on fargate:

Sending tracing information to AWS X-Ray

  • Related