|
| 1 | +import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; |
| 2 | + |
| 3 | +describe('redis auto instrumentation', () => { |
| 4 | + afterAll(() => { |
| 5 | + cleanupChildProcesses(); |
| 6 | + }); |
| 7 | + |
| 8 | + test('should auto-instrument `ioredis` package when using redis.set() and redis.get()', done => { |
| 9 | + const EXPECTED_TRANSACTION = { |
| 10 | + transaction: 'Test Transaction', |
| 11 | + spans: expect.arrayContaining([ |
| 12 | + expect.objectContaining({ |
| 13 | + description: 'set test-key [1 other arguments]', |
| 14 | + op: 'db', |
| 15 | + data: expect.objectContaining({ |
| 16 | + 'db.system': 'redis', |
| 17 | + 'net.peer.name': 'localhost', |
| 18 | + 'net.peer.port': 6379, |
| 19 | + 'db.statement': 'set test-key [1 other arguments]', |
| 20 | + }), |
| 21 | + }), |
| 22 | + expect.objectContaining({ |
| 23 | + description: 'get test-key', |
| 24 | + op: 'db', |
| 25 | + data: expect.objectContaining({ |
| 26 | + 'db.system': 'redis', |
| 27 | + 'net.peer.name': 'localhost', |
| 28 | + 'net.peer.port': 6379, |
| 29 | + 'db.statement': 'get test-key', |
| 30 | + }), |
| 31 | + }), |
| 32 | + ]), |
| 33 | + }; |
| 34 | + |
| 35 | + createRunner(__dirname, 'scenario-ioredis.js') |
| 36 | + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] }) |
| 37 | + .expect({ transaction: EXPECTED_TRANSACTION }) |
| 38 | + .start(done); |
| 39 | + }); |
| 40 | +}); |
0 commit comments