-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
55 lines (51 loc) · 1.78 KB
/
test.ts
File metadata and controls
55 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import type { TransactionEvent } from '@sentry/core';
import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
const EXPECTED_MESSAGE_SPAN_PRODUCER = expect.objectContaining({
op: 'message',
data: expect.objectContaining({
'messaging.system': 'rabbitmq',
'otel.kind': 'PRODUCER',
'sentry.op': 'message',
'sentry.origin': 'auto.amqplib.otel.publisher',
}),
status: 'ok',
});
const EXPECTED_MESSAGE_SPAN_CONSUMER = expect.objectContaining({
op: 'message',
data: expect.objectContaining({
'messaging.system': 'rabbitmq',
'otel.kind': 'CONSUMER',
'sentry.op': 'message',
'sentry.origin': 'auto.amqplib.otel.consumer',
}),
status: 'ok',
});
describe('amqplib auto-instrumentation', () => {
afterAll(async () => {
cleanupChildProcesses();
});
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => {
test('should be able to send and receive messages', { timeout: 60_000 }, async () => {
await createTestRunner()
.withDockerCompose({
workingDirectory: [__dirname],
})
.expect({
transaction: (transaction: TransactionEvent) => {
expect(transaction.transaction).toEqual('root span');
expect(transaction.spans?.length).toEqual(1);
expect(transaction.spans![0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);
},
})
.expect({
transaction: (transaction: TransactionEvent) => {
expect(transaction.transaction).toEqual('queue1 process');
expect(transaction.contexts?.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
},
})
.start()
.completed();
});
});
});