Skip to content

Why are my X-Ray sampling rules being ignored for my Node.js app running in EC2?

0

I have a Node.js app running in EC2 and have successfully launched the X-Ray collector using user data. The X-Ray service is getting the traces from the application (instrumented using the javascript xray-sdk), but I see no trend information in the sampling rules I have set up in the AWS console (including the default rule).

My code to initialize the sdk is pretty simple:

const AWS = AWSXRay.captureAWS(require('aws-sdk'));
AWS.config.update({ region: process.env.DEFAULT_AWS_REGION || 'us-west-2' });

...

app.use(AWSXRay.express.closeSegment());

...

app.use(AWSXRay.express.closeSegment());

I have also added code to use the AWS sdk to query for and log the sampling rules to see if they are visible to the app, and they are. I have not called AWSXRay.middleware.disableCentralizedSampling(), so I don't know why the sampling rules are not being used.

Is there some other configuration I need to set up to allow the rules to be used?

asked 3 years ago815 views
1 Answer
0

Centralized sampling rules are stored in X-Ray service. X-Ray sdk in user application has to take time to poll it and this poll action is lazy initialization, triggered by the first segment. So, the first segment generated in user application will fall back to a local rule (1/sec + 5%), which means the first segment is always sampled.

X-Ray centralized sampling has some limits, it does not work well in such cases:

  1. Instrumented application's life is short. Centralized sampling rules is not ready to take effect.
  2. If user's fleet scale is large, poll centralized sampling rules and sync up status with X-Ray service would take more time.

The alternative solution is using local sampling rules.

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.