Expected behaviour
DD-trace not crashing
Actual behaviour
DD-trace crashes with:
./node_modules/dd-trace/packages/datadog-plugin-pg/src/index.js:31
query.text = this.injectDbmQuery(query.text, service)
^
TypeError: Cannot set property text of #<SQLStatement> which has only a getter
at PGPlugin.start (/Users/hokasan/src/---/node_modules/dd-trace/packages/datadog-plugin-pg/src/index.js:31:16)
at /Users/hokasan/src/---/node_modules/dd-trace/packages/dd-trace/src/plugins/tracing.js:16:12
at Subscription._handler (/Users/hokasan/src/---/node_modules/dd-trace/packages/dd-trace/src/plugins/plugin.js:14:9)
at Channel.publish (node:diagnostics_channel:56:9)
at /Users/hokasan/src/---/node_modules/dd-trace/packages/datadog-instrumentations/src/pg.js:37:15
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at Client.query (/Users/hokasan/src/---/node_modules/dd-trace/packages/datadog-instrumentations/src/pg.js:36:26)
at PendingItem.callback (/Users/hokasan/src/---/node_modules/pg-pool/index.js:412:16)
at BoundPool._acquireClient (/Users/hokasan/src/---/node_modules/pg-pool/index.js:301:21)
at BoundPool._pulseQueue (/Users/hokasan/src/---/node_modules/pg-pool/index.js:146:19)
at /Users/hokasan/src/---/node_modules/pg-pool/index.js:179:37
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Steps to reproduce
Use "sql-template-strings" library to create your queries like this:
await client.query(SQL'
insert into classes_earlywarningsystemcommentlog (
created, modified, comment, admin_id, course_definition_id, student_id)
values (now(), now(), ${comment}, ${user.id}, ${courseId}, ${studentId});
');
query.text looks like this:
insert into classes_earlywarningsystemcommentlog (
created, modified, comment, admin_id, course_definition_id, student_id)
values (now(), now(), $1, $2, $3, $4);
Environment
- Operation system:
- MacOS and Ubunti
- Node.js version:
- 18.11.0
- Tracer version:
- 3.20.0
- Agent version:
- gcr.io/datadoghq/agent:7
- Relevant library versions:
Package.json
{
"main": "index.js",
"version": "1.4.2",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js",
"loadTest": "artillery run artillery.yml"
},
"dependencies": {
"@google-cloud/storage": "^5.3.0",
"@pinecone-database/pinecone": "^0.0.14",
"apollo-server-express": "2.26.1",
"aws-sdk": "^2.1159.0",
"bluebird": "^3.7.2",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dd-trace": "^3.20.0",
"dotenv": "^8.2.0",
"express": "^4.18.2",
"google-auth-library": "^6.1.0",
"googleapis": "^52.1.0",
"gql-query-builder": "^3.5.5",
"graphql": "^15.8.0",
"http": "^0.0.1-security",
"langchain": "^0.0.59",
"lodash": "^4.17.15",
"moment": "^2.27.0",
"njwt": "^2.0.0",
"nodemailer": "^6.7.7",
"parse": "^3.3.1",
"pbkdf2-sha256": "^1.1.1",
"pg": "^8.2.1",
"sql-template-strings": "^2.2.2",
"sqlstring": "^2.3.2",
"uid": "^1.0.0",
"uuid": "^8.3.0"
},
"devDependencies": {
"artillery": "^2.0.0-15",
"eslint-plugin-node": "^11.1.0"
},
"devDependenciesComments": {
"easygraphql-load-tester": "^2.0.5 (Add this to load test. Requires graphql14 so does not build in production)"
}
}
Expected behaviour
DD-trace not crashing
Actual behaviour
DD-trace crashes with:
Steps to reproduce
Use "sql-template-strings" library to create your queries like this:
query.text looks like this:
Environment
Package.json
{ "main": "index.js", "version": "1.4.2", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node index.js", "loadTest": "artillery run artillery.yml" }, "dependencies": { "@google-cloud/storage": "^5.3.0", "@pinecone-database/pinecone": "^0.0.14", "apollo-server-express": "2.26.1", "aws-sdk": "^2.1159.0", "bluebird": "^3.7.2", "body-parser": "^1.19.0", "cors": "^2.8.5", "dd-trace": "^3.20.0", "dotenv": "^8.2.0", "express": "^4.18.2", "google-auth-library": "^6.1.0", "googleapis": "^52.1.0", "gql-query-builder": "^3.5.5", "graphql": "^15.8.0", "http": "^0.0.1-security", "langchain": "^0.0.59", "lodash": "^4.17.15", "moment": "^2.27.0", "njwt": "^2.0.0", "nodemailer": "^6.7.7", "parse": "^3.3.1", "pbkdf2-sha256": "^1.1.1", "pg": "^8.2.1", "sql-template-strings": "^2.2.2", "sqlstring": "^2.3.2", "uid": "^1.0.0", "uuid": "^8.3.0" }, "devDependencies": { "artillery": "^2.0.0-15", "eslint-plugin-node": "^11.1.0" }, "devDependenciesComments": { "easygraphql-load-tester": "^2.0.5 (Add this to load test. Requires graphql14 so does not build in production)" } }