-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
119 lines (115 loc) · 4.03 KB
/
test.ts
File metadata and controls
119 lines (115 loc) · 4.03 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import type { SerializedLog } from '@sentry/core';
import { afterAll, describe, expect, test } from 'vitest';
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';
const commonAttributes: SerializedLog['attributes'] = {
'sentry.environment': {
type: 'string',
value: 'test',
},
'sentry.release': {
type: 'string',
value: '1.0.0',
},
'sentry.sdk.name': {
type: 'string',
value: 'sentry.javascript.node',
},
'sentry.sdk.version': {
type: 'string',
value: expect.any(String),
},
'sentry.timestamp.sequence': {
type: 'integer',
value: expect.any(Number),
},
'server.address': {
type: 'string',
value: expect.any(String),
},
};
describe('logs', () => {
afterAll(() => {
cleanupChildProcesses();
});
test('captures logs with scope and log attributes', async () => {
const runner = createRunner(__dirname, 'scenario.ts')
.expect({
log: logsContainer => {
expect(logsContainer).toEqual({
items: [
{
timestamp: expect.any(Number),
level: 'info',
body: 'log_before_any_scope',
severity_number: 9,
trace_id: expect.any(String),
attributes: {
...commonAttributes,
log_attr: { value: 'log_attr_1', type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
body: 'log_after_global_scope',
severity_number: 9,
trace_id: expect.any(String),
attributes: {
...commonAttributes,
global_scope_attr: { value: true, type: 'boolean' },
array_attr: { value: [1, 2, 3], type: 'array' },
log_attr: { value: 'log_attr_2', type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
body: 'log_with_isolation_scope',
severity_number: 9,
trace_id: expect.any(String),
attributes: {
...commonAttributes,
global_scope_attr: { value: true, type: 'boolean' },
array_attr: { value: [1, 2, 3], type: 'array' },
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
log_attr: { value: 'log_attr_3', type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
body: 'log_with_scope',
severity_number: 9,
trace_id: expect.any(String),
attributes: {
...commonAttributes,
global_scope_attr: { value: true, type: 'boolean' },
array_attr: { value: [1, 2, 3], type: 'array' },
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
scope_attr: { value: 200, unit: 'millisecond', type: 'integer' },
log_attr: { value: 'log_attr_4', type: 'string' },
},
},
{
timestamp: expect.any(Number),
level: 'info',
body: 'log_with_scope_2',
severity_number: 9,
trace_id: expect.any(String),
attributes: {
...commonAttributes,
global_scope_attr: { value: true, type: 'boolean' },
array_attr: { value: [1, 2, 3], type: 'array' },
isolation_scope_1_attr: { value: 100, unit: 'millisecond', type: 'integer' },
scope_2_attr: { value: 300, unit: 'millisecond', type: 'integer' },
log_attr: { value: 'log_attr_5', type: 'string' },
},
},
],
});
},
})
.start();
await runner.completed();
});
});