|
| 1 | +import { conditionalTest } from '../../../utils'; |
| 2 | +import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; |
| 3 | + |
| 4 | +jest.setTimeout(75000); |
| 5 | + |
| 6 | +// Tedious version we are testing against only supports Node 18+ |
| 7 | +// https://github.com/tediousjs/tedious/blob/8310c455a2cc1cba83c1ca3c16677da4f83e12a9/package.json#L38 |
| 8 | +conditionalTest({ min: 18 })('tedious auto instrumentation', () => { |
| 9 | + afterAll(() => { |
| 10 | + cleanupChildProcesses(); |
| 11 | + }); |
| 12 | + |
| 13 | + test('should auto-instrument `tedious` package', done => { |
| 14 | + const EXPECTED_TRANSACTION = { |
| 15 | + transaction: 'Test Transaction', |
| 16 | + spans: expect.arrayContaining([ |
| 17 | + expect.objectContaining({ |
| 18 | + description: 'SELECT GETDATE()', |
| 19 | + data: expect.objectContaining({ |
| 20 | + 'sentry.origin': 'auto.db.otel.tedious', |
| 21 | + 'sentry.op': 'db', |
| 22 | + 'db.name': 'master', |
| 23 | + 'db.statement': 'SELECT GETDATE()', |
| 24 | + 'db.system': 'mssql', |
| 25 | + 'db.user': 'sa', |
| 26 | + 'net.peer.name': '127.0.0.1', |
| 27 | + 'net.peer.port': 1433, |
| 28 | + }), |
| 29 | + status: 'ok', |
| 30 | + }), |
| 31 | + expect.objectContaining({ |
| 32 | + description: 'SELECT 1 + 1 AS solution', |
| 33 | + data: expect.objectContaining({ |
| 34 | + 'sentry.origin': 'auto.db.otel.tedious', |
| 35 | + 'sentry.op': 'db', |
| 36 | + 'db.name': 'master', |
| 37 | + 'db.statement': 'SELECT 1 + 1 AS solution', |
| 38 | + 'db.system': 'mssql', |
| 39 | + 'db.user': 'sa', |
| 40 | + 'net.peer.name': '127.0.0.1', |
| 41 | + 'net.peer.port': 1433, |
| 42 | + }), |
| 43 | + status: 'ok', |
| 44 | + }), |
| 45 | + ]), |
| 46 | + }; |
| 47 | + |
| 48 | + createRunner(__dirname, 'scenario.js') |
| 49 | + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['1433'] }) |
| 50 | + .expect({ transaction: EXPECTED_TRANSACTION }) |
| 51 | + .start(done); |
| 52 | + }); |
| 53 | +}); |
0 commit comments