Skip to content

Commit f1ae71b

Browse files
authored
Merge pull request #667 from dwickr/prefix-sql-url-with-scheme
Prefix SQL URLs with scheme
2 parents 76ce2ed + 8d9e6bf commit f1ae71b

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

packages/mysql/lib/mysql_p.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function captureOperation(name) {
272272
function createSqlData(config, values, sql) {
273273
var commandType = values ? PREPARED : null;
274274
var data = new SqlData(DATABASE_VERS, DRIVER_VERS, config.user,
275-
config.host + ':' + config.port + '/' + config.database,
275+
'mysql://' + config.host + ':' + config.port + '/' + config.database,
276276
commandType);
277277

278278
if (process.env.AWS_XRAY_COLLECT_SQL_QUERIES && sql) {

packages/mysql/test/unit/mysql_p.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('captureMySQL', function() {
144144
query.call(connectionObj, 'sql here', [1]);
145145

146146
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, config.user,
147-
config.host + ':' + config.port + '/' + config.database, 'statement');
147+
'mysql://' + config.host + ':' + config.port + '/' + config.database, 'statement');
148148
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
149149
});
150150

@@ -256,7 +256,7 @@ describe('captureMySQL', function() {
256256
query.call(connectionObj, 'sql here', [1]);
257257

258258
stubDataInit.should.have.been.calledWithExactly(process.env.MYSQL_DATABASE_VERSION, process.env.MYSQL_DRIVER_VERSION,
259-
conParam.user, conParam.host + ':' + conParam.port + '/' + conParam.database, 'statement');
259+
conParam.user, 'mysql://' + conParam.host + ':' + conParam.port + '/' + conParam.database, 'statement');
260260
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
261261
stubAddSql.should.have.been.calledWithExactly(sinon.match.has('sanitized_query', 'sql here'));
262262
});
@@ -269,7 +269,7 @@ describe('captureMySQL', function() {
269269
query.call(connectionObj, 'sql here', [1]);
270270

271271
stubDataInit.should.have.been.calledWithExactly(process.env.MYSQL_DATABASE_VERSION, process.env.MYSQL_DRIVER_VERSION,
272-
conParam.user, conParam.host + ':' + conParam.port + '/' + conParam.database, 'statement');
272+
conParam.user, 'mysql://' + conParam.host + ':' + conParam.port + '/' + conParam.database, 'statement');
273273
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
274274
sinon.assert.match(sinon.match, {
275275
'sanitized_query': undefined
@@ -349,7 +349,7 @@ describe('captureMySQL', function() {
349349

350350
resolvedConn.query('sql here').then(function() {
351351
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, config.user,
352-
config.host + ':' + config.port + '/' + config.database, 'statement');
352+
'mysql://' + config.host + ':' + config.port + '/' + config.database, 'statement');
353353
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
354354
});
355355
});
@@ -460,7 +460,7 @@ describe('captureMySQL', function() {
460460
query.call(connectionObj, 'sql here', [1]);
461461

462462
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, config.user,
463-
config.host + ':' + config.port + '/' + config.database, 'statement');
463+
'mysql://' + config.host + ':' + config.port + '/' + config.database, 'statement');
464464
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
465465
});
466466

@@ -556,7 +556,7 @@ describe('captureMySQL', function() {
556556
query.call(connectionObj, 'sql here', [1]);
557557

558558
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, config.user,
559-
config.host + ':' + config.port + '/' + config.database, 'statement');
559+
'mysql://' + config.host + ':' + config.port + '/' + config.database, 'statement');
560560
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
561561
});
562562

@@ -703,7 +703,7 @@ describe('captureMySQL', function() {
703703
query.call(connectionObj, 'sql here', [1]);
704704

705705
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, config.user,
706-
config.host + ':' + config.port + '/' + config.database, 'statement');
706+
'mysql://' + config.host + ':' + config.port + '/' + config.database, 'statement');
707707
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
708708
});
709709

packages/postgres/lib/postgres_p.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function createSqlData(connParams, query) {
126126
var queryType = query.name ? PREPARED : undefined;
127127

128128
var data = new SqlData(DATABASE_VERS, DRIVER_VERS, connParams.user,
129-
connParams.host + ':' + connParams.port + '/' + connParams.database,
129+
'postgresql://' + connParams.host + ':' + connParams.port + '/' + connParams.database,
130130
queryType);
131131
if (process.env.AWS_XRAY_COLLECT_SQL_QUERIES) {
132132
data.sanitized_query = query.text;

packages/postgres/test/unit/postgres_p.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('capturePostgres', function() {
8686
query.call(postgres, 'sql here');
8787

8888
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, conParam.user,
89-
conParam.host + ':' + conParam.port + '/' + conParam.database, undefined);
89+
'postgresql://' + conParam.host + ':' + conParam.port + '/' + conParam.database, undefined);
9090
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
9191
});
9292

@@ -100,7 +100,7 @@ describe('capturePostgres', function() {
100100
query.call(postgres, 'sql here');
101101

102102
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, conParam.user,
103-
conParam.host + ':' + conParam.port + '/' + conParam.database, undefined);
103+
'postgresql://' + conParam.host + ':' + conParam.port + '/' + conParam.database, undefined);
104104
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
105105
stubAddSql.should.have.been.calledWithExactly(sinon.match.has('sanitized_query', 'sql statement here'));
106106
});
@@ -227,7 +227,7 @@ describe('capturePostgres', function() {
227227
query.call(postgres, 'sql here');
228228

229229
stubDataInit.should.have.been.calledWithExactly(undefined, undefined, conParam.user,
230-
conParam.host + ':' + conParam.port + '/' + conParam.database, undefined);
230+
'postgresql://' + conParam.host + ':' + conParam.port + '/' + conParam.database, undefined);
231231
stubAddSql.should.have.been.calledWithExactly(sinon.match.instanceOf(SqlData));
232232
});
233233

0 commit comments

Comments
 (0)