Skip to content
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 dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"mongodb-memory-server-global": "^11.0.1",
"mongoose": "^6.13.10",
"mysql": "^2.18.1",
"mysql2": "^3.19.1",
"mysql2": "^3.23.3",
"nock": "^14.0.17",
"node-cron": "^4.6.0",
"node-schedule": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { cleanupChildProcesses, createEsmAndCjsTests, describeWithDockerCompose

// mysql2 >= 3.20.0 publishes its operations via `node:diagnostics_channel`, so the SDK subscribes
// to those channels (`subscribeMysql2DiagnosticChannels`) instead of monkey-patching. This suite
// pins `^3.20.0` and asserts the diagnostics-channel path: stable OTel DB semconv attributes,
// redacted query text, and that the legacy IITM patcher (gated to `< 3.20.0`) does NOT also fire.
// runs against the workspace version and asserts the diagnostics-channel path: stable OTel DB
// semconv attributes, redacted query text, and that the legacy IITM patcher (gated to `< 3.20.0`)
// does NOT also fire. A workspace downgrade below 3.20.0 fails the double-instrumentation test.
describe('mysql2 tracing channel Test', () => {
afterAll(() => {
cleanupChildProcesses();
Expand Down Expand Up @@ -44,50 +45,44 @@ describe('mysql2 tracing channel Test', () => {
};

describeWithDockerCompose('with pg docker compose', { workingDirectory: [__dirname] }, () => {
createEsmAndCjsTests(
__dirname,
'scenario.mjs',
'instrument.mjs',
(createTestRunner, test) => {
test('subscribes to mysql2 >= 3.20.0 diagnostics channels with stable semconv attributes', async () => {
await createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed();
}, 30_000);
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => {
test('subscribes to mysql2 >= 3.20.0 diagnostics channels with stable semconv attributes', async () => {
await createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed();
}, 30_000);

test('does not double-instrument: the legacy IITM mysql2 patcher does not fire on 3.20.0+', async () => {
await createTestRunner()
.expect({
transaction: event => {
expect(event.transaction).toBe('Test Transaction');
const spans = event.spans || [];
// The monkey-patch path (origin `auto.db.otel.mysql2`) must be inactive on 3.20.0+.
expect(spans.find(span => span.origin === 'auto.db.otel.mysql2')).toBeUndefined();
// ...while the diagnostics-channel path is active.
expect(spans.find(span => span.origin === 'auto.db.mysql2.diagnostic_channel')).toBeDefined();
},
})
.start()
.completed();
}, 30_000);
test('does not double-instrument: the legacy IITM mysql2 patcher does not fire on 3.20.0+', async () => {
await createTestRunner()
.expect({
transaction: event => {
expect(event.transaction).toBe('Test Transaction');
const spans = event.spans || [];
// The monkey-patch path (origin `auto.db.otel.mysql2`) must be inactive on 3.20.0+.
expect(spans.find(span => span.origin === 'auto.db.otel.mysql2')).toBeUndefined();
// ...while the diagnostics-channel path is active.
expect(spans.find(span => span.origin === 'auto.db.mysql2.diagnostic_channel')).toBeDefined();
},
})
.start()
.completed();
}, 30_000);

test('never leaks raw values into db.query.text', async () => {
await createTestRunner()
.expect({
transaction: event => {
expect(event.transaction).toBe('Test Transaction');
const spans = event.spans || [];
for (const span of spans) {
const queryText = span.data?.['db.query.text'];
if (typeof queryText === 'string') {
expect(queryText).not.toContain('super-secret');
}
test('never leaks raw values into db.query.text', async () => {
await createTestRunner()
.expect({
transaction: event => {
expect(event.transaction).toBe('Test Transaction');
const spans = event.spans || [];
for (const span of spans) {
const queryText = span.data?.['db.query.text'];
if (typeof queryText === 'string') {
expect(queryText).not.toContain('super-secret');
}
},
})
.start()
.completed();
}, 30_000);
},
{ additionalDependencies: { mysql2: '^3.20.0' } },
);
}
},
})
.start()
.completed();
}, 30_000);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ describeWithDockerCompose('mysql2 auto instrumentation', { workingDirectory: [__
]),
};

createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => {
test('should auto-instrument `mysql2` package without connection.connect()', { timeout: 75_000 }, async () => {
await createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed();
});
});
createEsmAndCjsTests(
__dirname,
'scenario.mjs',
'instrument.mjs',
(createTestRunner, test) => {
test('should auto-instrument `mysql2` package without connection.connect()', { timeout: 75_000 }, async () => {
await createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed();
});
},
// mysql2 >= 3.20.0 publishes its own diagnostics channels, which the SDK subscribes to instead
// of the orchestrion path asserted here. That range is covered by `mysql2-tracing-channel`, so
// this suite pins a version below the boundary regardless of the version the workspace installs.
{ additionalDependencies: { mysql2: '3.19.1' } },
);
});
29 changes: 14 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17381,10 +17381,10 @@ iconv-lite@^0.4.24, iconv-lite@~0.4.24:
dependencies:
safer-buffer ">= 2.1.2 < 3"

iconv-lite@^0.7.0, iconv-lite@^0.7.2, iconv-lite@~0.7.0:
version "0.7.2"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.7.2.tgz#d0bdeac3f12b4835b7359c2ad89c422a4d1cc72e"
integrity sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==
iconv-lite@^0.7.0, iconv-lite@^0.7.2, iconv-lite@^0.7.3, iconv-lite@~0.7.0:
version "0.7.3"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.7.3.tgz#84ee12f963e7de50bc01a13e160a078b3b0f415f"
integrity sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==
dependencies:
safer-buffer ">= 2.1.2 < 3.0.0"

Expand Down Expand Up @@ -20347,19 +20347,18 @@ mute-stream@0.0.8:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==

mysql2@^3.19.1:
version "3.19.1"
resolved "https://registry.yarnpkg.com/mysql2/-/mysql2-3.19.1.tgz#1e9c88646cb2f0cb3d8df6ce56b8f4d6cbf6b013"
integrity sha512-yn4zh+Uxu5J3Zvi6Ao96lJ7BSBRkspHflWQAmOPND+htbpIKDQw99TTvPzgihKO/QyMickZopO4OsnixnpcUwA==
mysql2@^3.23.3:
version "3.23.3"
resolved "https://registry.yarnpkg.com/mysql2/-/mysql2-3.23.3.tgz#85247f36f35bd180d3ba18b1f60fa7d553960ee2"
integrity sha512-ehp9HEKr4wVJaBOUVxNFa+CNrsCCCZ6363/jbGhb7WpEmSRNIXjHBjFs5K2s2cXn7j/RhDieejsQJ6nfUwD6vQ==
dependencies:
aws-ssl-profiles "^1.1.2"
denque "^2.1.0"
generate-function "^2.3.1"
iconv-lite "^0.7.2"
iconv-lite "^0.7.3"
long "^5.3.2"
lru.min "^1.1.4"
named-placeholders "^1.1.6"
sql-escaper "^1.3.3"
sql-escaper "^1.5.1"

mysql@^2.18.1:
version "2.18.1"
Expand Down Expand Up @@ -25388,10 +25387,10 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

sql-escaper@^1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/sql-escaper/-/sql-escaper-1.3.3.tgz#65faf89f048d26bb9a75566b82b5990ddf8a5b7f"
integrity sha512-BsTCV265VpTp8tm1wyIm1xqQCS+Q9NHx2Sr+WcnUrgLrQ6yiDIvHYJV5gHxsj1lMBy2zm5twLaZao8Jd+S8JJw==
sql-escaper@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/sql-escaper/-/sql-escaper-1.5.1.tgz#fbaee511294d1f7da92fb68ca1faee2255839c7b"
integrity sha512-4toX5E1fQbBrpfXidaHnF0669nkAdETeIPTs2SUjxxD7RRIs9ICG4gtpmfc68JCEKehsdwLFqBu9VlQqZ1P1gg==

sqlstring@2.3.1:
version "2.3.1"
Expand Down
Loading