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