Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

307
Vistas
AWS XRay with AWS SDK v3 for NodeJS

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

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use v3 compatible x-ray-sdk capture function captureAWSv3Client

Here is working snippet:

const {DynamoDBClient, ScanCommand} = require("@aws-sdk/client-dynamodb");
const AWSXRay = require("aws-xray-sdk-core");

const dynamoClient = AWSXRay.captureAWSv3Client(
    new DynamoDBClient({})
)

const scan = new ScanCommand({
    TableName: 'xxx',
});

const response = await dynamoClient.send(scan)

It is also important to have permissions to write into X-Ray eg:

Policies:
  - AWSXrayWriteOnlyAccess
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda