OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

AWS XRay with AWS SDK v3 for NodeJS

  • Thread starter Thread starter Martin Macak
  • Start date Start date
M

Martin Macak

Guest
Is there any way how to use XRay instrumentation for AWS NodeJS SDK v3? In SDK v2, AWSXray was able to capture any client and instrument it for tracing into XRay. I have been trying the same thing with v3 with following snippet

Code:
const  {DynamoDBClient, ScanCommand} = require("@aws-sdk/client-dynamodb");
const AWSXRay = require("aws-xray-sdk");
// if uncommented, this throws an exception
// AWSXRay.captureAWSClient(DynamoDBClient); 

const client = new DynamoDBClient({region: process.env.AWS_REGION});
// if uncommented, this throws an exception
// AWSXRay.captureAWSClient(client);

const scan = new ScanCommand({
    TableName: 'xxx',
});
await client.send(scan) //?

but both commented lines throw service.customizeRequests is not a function. This seems like AWS SDK s3 is not backward-compatible with original AWSXRay library.

I found that SDK v3 contains XRay client, but this is just a client that can send spans and traces into AWS, not an instrumentation agent.

What's recommended pattern of using XRay instrumentation with AWS SDK v3 for NodeJS?

<p>Is there any way how to use XRay instrumentation for AWS NodeJS SDK v3? In SDK v2, AWSXray was able to capture any client and instrument it for tracing into XRay.
I have been trying the same thing with v3 with following snippet</p>
<pre class="lang-js prettyprint-override"><code>const {DynamoDBClient, ScanCommand} = require("@aws-sdk/client-dynamodb");
const AWSXRay = require("aws-xray-sdk");
// if uncommented, this throws an exception
// AWSXRay.captureAWSClient(DynamoDBClient);

const client = new DynamoDBClient({region: process.env.AWS_REGION});
// if uncommented, this throws an exception
// AWSXRay.captureAWSClient(client);

const scan = new ScanCommand({
TableName: 'xxx',
});
await client.send(scan) //?

</code></pre>
<p>but both commented lines throw <code>service.customizeRequests is not a function</code>. This seems like AWS SDK s3 is not backward-compatible with original AWSXRay library.</p>
<p>I found that SDK v3 contains XRay client, but this is just a client that can send spans and traces into AWS, not an instrumentation agent.</p>
<p>What's recommended pattern of using XRay instrumentation with AWS SDK v3 for NodeJS?</p>
 

Latest posts

G
Replies
0
Views
1
Gamal Othman
G
Top