aws / aws/aws-xray-sdk-node

patchCreatePoolCluster return unpatch object.

Open
#256 2 comments 0 reactions 1 assignee Claimed by @willarmiros View on GitHub
bug
Dominant language
JavaScript
Stars
280
Forks
157
PR merge metrics
No merged PRs in 30d

Description

Versions:
"@types/mysql": "2.15.9",
"mysql": "2.13.0",
"nodejs": "10.16.0"

We can not get my SQL data in X-RAy.
We are working with "poolClusters" and when I call the createPoolCluster function it seems that we are getting back an object with no xray wrappers.
```

const AWS = require("aws-xray-sdk");
var mysql = AWS.captureMySQL(require("mysql"))
var poolCluster = mysql.createPoolCluster();
poolCluster.add("MASTER", defaultOptionsForConnectPools.MASTER);

```
We trace it to a check of query function in the poolCluster object which does not exist by design.

```
function patchCreatePoolCluster(mysql) {
var baseFcn = '__createPoolCluster';
mysql[baseFcn] = mysql['createPoolCluster'];

mysql['createPoolCluster'] = function patchedCreatePoolCluster() {
console.log(arguments);
var poolCluster = mysql[baseFcn].apply(poolCluster, arguments);
if (poolCluster.query instanceof Function) {
patchObject(poolCluster);
}
return poolCluster;
};
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.