-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
104 lines (100 loc) · 4.03 KB
/
test.ts
File metadata and controls
104 lines (100 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
import { expect } from '@playwright/test';
import type { MetricEnvelope } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
sentryTest('should capture all metric types', async ({ getLocalTestUrl, page }) => {
const bundle = process.env.PW_BUNDLE || '';
if (bundle.startsWith('bundle') || bundle.startsWith('loader')) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
const event = await getFirstSentryEnvelopeRequest<MetricEnvelope>(page, url, properFullEnvelopeRequestParser);
const envelopeItems = event[1];
expect(envelopeItems[0]).toEqual([
{
type: 'trace_metric',
item_count: 5,
content_type: 'application/vnd.sentry.items.trace-metric+json',
},
{
items: [
{
timestamp: expect.any(Number),
trace_id: expect.any(String),
name: 'test.counter',
type: 'counter',
value: 1,
attributes: {
endpoint: { value: '/api/test', type: 'string' },
'sentry.release': { value: '1.0.0', type: 'string' },
'sentry.environment': { value: 'test', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
trace_id: expect.any(String),
name: 'test.gauge',
type: 'gauge',
unit: 'millisecond',
value: 42,
attributes: {
server: { value: 'test-1', type: 'string' },
'sentry.release': { value: '1.0.0', type: 'string' },
'sentry.environment': { value: 'test', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
trace_id: expect.any(String),
name: 'test.distribution',
type: 'distribution',
unit: 'second',
value: 200,
attributes: {
priority: { value: 'high', type: 'string' },
'sentry.release': { value: '1.0.0', type: 'string' },
'sentry.environment': { value: 'test', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
trace_id: expect.any(String),
span_id: expect.any(String),
name: 'test.span.counter',
type: 'counter',
value: 1,
attributes: {
operation: { value: 'test', type: 'string' },
'sentry.release': { value: '1.0.0', type: 'string' },
'sentry.environment': { value: 'test', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
{
timestamp: expect.any(Number),
trace_id: expect.any(String),
name: 'test.user.counter',
type: 'counter',
value: 1,
attributes: {
action: { value: 'click', type: 'string' },
'user.id': { value: 'user-123', type: 'string' },
'user.email': { value: 'test@example.com', type: 'string' },
'user.name': { value: 'testuser', type: 'string' },
'sentry.release': { value: '1.0.0', type: 'string' },
'sentry.environment': { value: 'test', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
},
},
],
},
]);
});