-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for nodejs mysql2 package #6
Comments
I have a bit of time. I can take a look at it if no one else is on it. |
Appreciate it 👍 |
We also need the mysql2 client. Mostly due to the support for prepared statements. See http://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-sqlclients.html var AWSXRay = require('aws-xray-sdk'); Can we do the following with mysql2? We need to use MYSQL2 for Prepared statements. https://github.com/sidorares/node-mysql2#using-prepared-statements var AWSXRay = require('aws-xray-sdk'); |
Hi billnbell, The patcher needs to be modified to gather data from the connection.execute call for mysql2. The current patcher will not extract the data for prepared statements. Additionally, for automatic mode, CLS does not support async/await so any async/await functionality in mysql2 will not be supported. Also, the SDK itself does not have promise support as of yet (although there is one WIP PR with a suggested solution for this we are reviewing at the moment) so that too would not be supported for mysql2 as of yet. |
OK. What is the estimated time for CLS to support async/await? I did notice this: https://github.com/othiym23/cls-middleware Wondering if that could help the team? |
Any updates on supporting mysql2? we would like to use this with sequelize. |
I submitted #62 as a first attempt to support mysql2: just If that is accepted, then I would be willing tackle prepared statements. |
#62 has been merged. I will tackle prepared statements tomorrow. |
I got this message. Do you know what it mean? |
@kh01 hi there, are you using the head of this repo with #62 or just the official release SDK? Do you have a code snippet where it generates this error? A SQL transactions is usually a subtask of serving an event/request so it is captured as a subsegment. It needs a parent segment/subsegment which represents the parent task. If the tracing context is not preserved when the SQL transaction happens, then the SDK doesn't know which parent to attach to resulting in an error like this. You can learn more about the segment/subsegment concepts here: https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-segments |
@haotianw465: I'm using the official release. I think it has to do with how tracing context for async/await. |
Any workaround to wrap I tried import mysql from "mysql2"; // v1.6.4
import captureMySQL from "aws-xray-sdk-mysql"; // v2.1.0
captureMySQL(mysql);
const mysqlPromise = require("mysql2/promise");
const pool = mysqlPromise.createPool({
user, password, database, host, port,
ssl : "Amazon RDS",
connectionLimit : 1
});
await pool.execute("SELECT * FROM table"); // <-- Using `query` works BTW But tracing is throwing in
PS: Even when manually wrapping the callback in a promise, I get the sam error 🤔 Edit: Ok I found a workaround, the problem is with |
The problem with |
Support for mysql2 (promisified queries) should be available with the |
@willarmiros Based on the previous conversation and above comments, I have used the modules but it does not work as expected. aws-xray-sdk does not log the mysql query in aws-xray. I have another different solution, but it requires a lot of rework. Hence this would be the best feasible solutions. I have also referred following link, but it does not work.
|
Is there any possibility that support will be added for the module
mysql2
?The text was updated successfully, but these errors were encountered: