JSPM

  • Created
  • Published
  • Downloads 382643
  • Score
    100M100P100Q189865F
  • License Apache-2.0

AWS X-Ray Patcher for MySQL (Javascript)

Package Exports

  • aws-xray-sdk-mysql

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-xray-sdk-mysql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Requirements

AWS X-Ray SDK Core MySQL 2.12.0 or greater

AWS X-Ray and MySQL

AWS X-Ray MySQL package automatically records query information, request and response data. Simply patch the MySQL package via 'captureMySQL' as seen below.

The AWS X-Ray SDK Core has two modes - 'manual' and 'automatic'. Automatic mode uses the Continuation Local Storage package (CLS) and automatically keeps track of the current segment and subsegment. This is the default mode. Manual mode requires you pass around the segment reference. See examples below.

environment variables

MYSQL_DATABASE_VERSION           Sets additional data for the sql subsegment.
MYSQL_DRIVER_VERSION             Sets additional data for the sql subsegment.

Automatic mode example

var AWSXRay = require('aws-xray-sdk-core');
var captureMySQL = require('aws-xray-sdk-mysql');

var mysql = captureMySQL(require('mysql'));

var config = { ... };

...

var connection = mysql.createConnection(config);

connection.query('SELECT * FROM cats', function(err, rows) {
  //automatically captures query information and error (if any)
});

...

var pool = mysql.createPool(config);

pool.query('SELECT * FROM cats', function(err, rows, fields) {
  //automatically captures query information and error (if any)
}

Manual mode example

var AWSXRay = require('aws-xray-sdk-core');
var captureMySQL = require('aws-xray-sdk-mysql');

var mysql = captureMySQL(require('mysql'));

var config = { ... };

...

var connection = mysql.createConnection(config);

connection.query('SELECT * FROM cats', function(err, rows) {
  //automatically captures query information and error (if any)
});

...

var pool = mysql.createPool(config);

pool.query('SELECT * FROM cats', function(err, rows, fields) {
  //automatically captures query information and error (if any)
}, segment);