Socket
Socket
Sign inDemoInstall

aws-xray-sdk-mysql

Package Overview
Dependencies
18
Maintainers
24
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    aws-xray-sdk-mysql

AWS X-Ray Patcher for MySQL (Javascript)


Version published
Weekly downloads
270K
increased by2.01%
Maintainers
24
Install size
2.08 MB
Created
Weekly downloads
 

Readme

Source

Requirements

  • AWS X-Ray SDK Core
  • MySQL 2.12.0 or greater

AWS X-Ray and MySQL

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

The AWS X-Ray SDK Core has two modes - manual and automatic. Automatic mode uses the cls-hooked package and automatically tracks the current segment and subsegment. This is the default mode. Manual mode requires that you pass around the segment reference. See the examples below.

Environment variables

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

Lambda Example

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

...

exports.handler = function (event, context, callback) {
  // Make MySQL queries normally
}

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 errors (if any)
});

...

var pool = mysql.createPool(config);

pool.query('SELECT * FROM cats', function(err, rows, fields) {
  //Automatically captures query information and errors (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 errors (if any)
}, segment);

...

var pool = mysql.createPool(config);

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

Keywords

FAQs

Last updated on 25 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc