Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Tracing SQL Queries with the X-Ray SDK for Node.js

Instrument SQL database queries by wrapping your SQL client in the corresponding X-Ray SDK for Node.js client method.

  • PostgreSQLAWSXRay.capturePostgres()

    var AWSXRay = require('aws-xray-sdk'); var pg = AWSXRay.capturePostgres(require('pg')); var client = new pg.Client();
  • MySQLAWSXRay.captureMySQL()

    var AWSXRay = require('aws-xray-sdk'); var mysql = AWSXRay.captureMySQL(require('mysql')); ... var connection = mysql.createConnection(config);

When you use an instrumented client to make SQL queries, the X-Ray SDK for Node.js records information about the connection and query in a subsegment.