|
| 1 | +import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; |
| 2 | + |
| 3 | +// When running docker compose, we need a larger timeout, as this takes some time... |
| 4 | +jest.setTimeout(60_000); |
| 5 | + |
| 6 | +describe('kafkajs', () => { |
| 7 | + afterAll(() => { |
| 8 | + cleanupChildProcesses(); |
| 9 | + }); |
| 10 | + |
| 11 | + test('traces producers and consumers', done => { |
| 12 | + createRunner(__dirname, 'scenario.js') |
| 13 | + .withDockerCompose({ |
| 14 | + workingDirectory: [__dirname], |
| 15 | + readyMatches: ['9092'], |
| 16 | + }) |
| 17 | + .expect({ |
| 18 | + transaction: { |
| 19 | + transaction: 'test-topic', |
| 20 | + contexts: { |
| 21 | + trace: expect.objectContaining({ |
| 22 | + op: 'message', |
| 23 | + status: 'ok', |
| 24 | + data: expect.objectContaining({ |
| 25 | + 'messaging.system': 'kafka', |
| 26 | + 'messaging.destination': 'test-topic', |
| 27 | + 'otel.kind': 'PRODUCER', |
| 28 | + 'sentry.op': 'message', |
| 29 | + 'sentry.origin': 'auto.kafkajs.otel.producer', |
| 30 | + }), |
| 31 | + }), |
| 32 | + }, |
| 33 | + }, |
| 34 | + }) |
| 35 | + .expect({ |
| 36 | + transaction: { |
| 37 | + transaction: 'test-topic', |
| 38 | + contexts: { |
| 39 | + trace: expect.objectContaining({ |
| 40 | + op: 'message', |
| 41 | + status: 'ok', |
| 42 | + data: expect.objectContaining({ |
| 43 | + 'messaging.system': 'kafka', |
| 44 | + 'messaging.destination': 'test-topic', |
| 45 | + 'otel.kind': 'CONSUMER', |
| 46 | + 'sentry.op': 'message', |
| 47 | + 'sentry.origin': 'auto.kafkajs.otel.consumer', |
| 48 | + }), |
| 49 | + }), |
| 50 | + }, |
| 51 | + }, |
| 52 | + }) |
| 53 | + .start(done); |
| 54 | + }); |
| 55 | +}); |
0 commit comments