Skip to content
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

Prefix SQL URLs with scheme #667

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mysql/lib/mysql_p.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function captureOperation(name) {
function createSqlData(config, values, sql) {
var commandType = values ? PREPARED : null;
var data = new SqlData(DATABASE_VERS, DRIVER_VERS, config.user,
config.host + ':' + config.port + '/' + config.database,
'mysql://' + config.host + ':' + config.port + '/' + config.database,
commandType);

if (process.env.AWS_XRAY_COLLECT_SQL_QUERIES && sql) {
Expand Down
14 changes: 7 additions & 7 deletions packages/mysql/test/unit/mysql_p.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('captureMySQL', function() {
query.call(connectionObj, 'sql here', [1]);

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

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

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

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

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

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

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion packages/postgres/lib/postgres_p.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function createSqlData(connParams, query) {
var queryType = query.name ? PREPARED : undefined;

var data = new SqlData(DATABASE_VERS, DRIVER_VERS, connParams.user,
connParams.host + ':' + connParams.port + '/' + connParams.database,
'postgresql://' + connParams.host + ':' + connParams.port + '/' + connParams.database,
queryType);
if (process.env.AWS_XRAY_COLLECT_SQL_QUERIES) {
data.sanitized_query = query.text;
Expand Down
6 changes: 3 additions & 3 deletions packages/postgres/test/unit/postgres_p.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('capturePostgres', function() {
query.call(postgres, 'sql here');

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

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

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

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

Expand Down
Loading