Skip to content

Commit a67ebc4

Browse files
authored
ref(core): Switch to standardized log envelope (#16133)
To test logs for the alpha we used a standardized `otel_log` envelope item. Now that the logs protocol is more stable, we are switching to the sentry specific envelope item. This is fully documented here: https://develop.sentry.dev/sdk/telemetry/logs/
1 parent ffdd2dd commit a67ebc4

File tree

13 files changed

+630
-1219
lines changed

13 files changed

+630
-1219
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test';
2-
import type { OtelLogEnvelope } from '@sentry/core';
2+
import type { LogEnvelope } from '@sentry/core';
33
import { sentryTest } from '../../../../utils/fixtures';
44
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
55

@@ -12,237 +12,114 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
1212

1313
const url = await getLocalTestUrl({ testDir: __dirname });
1414

15-
const event = await getFirstSentryEnvelopeRequest<OtelLogEnvelope>(page, url, properFullEnvelopeRequestParser);
15+
const event = await getFirstSentryEnvelopeRequest<LogEnvelope>(page, url, properFullEnvelopeRequestParser);
1616
const envelopeItems = event[1];
1717

1818
expect(envelopeItems[0]).toEqual([
1919
{
20-
type: 'otel_log',
20+
type: 'log',
21+
item_count: 8,
22+
content_type: 'application/vnd.sentry.items.log+json',
2123
},
2224
{
23-
severityText: 'trace',
24-
body: { stringValue: 'console.trace 123 false' },
25-
attributes: [
25+
items: [
2626
{
27-
key: 'sentry.origin',
28-
value: {
29-
stringValue: 'auto.console.logging',
27+
timestamp: expect.any(Number),
28+
level: 'trace',
29+
severity_number: 1,
30+
trace_id: expect.any(String),
31+
body: 'console.trace 123 false',
32+
attributes: {
33+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
34+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
35+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
3036
},
3137
},
3238
{
33-
key: 'sentry.sdk.name',
34-
value: {
35-
stringValue: 'sentry.javascript.browser',
39+
timestamp: expect.any(Number),
40+
level: 'debug',
41+
severity_number: 5,
42+
trace_id: expect.any(String),
43+
body: 'console.debug 123 false',
44+
attributes: {
45+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
46+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
47+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
3648
},
3749
},
3850
{
39-
key: 'sentry.sdk.version',
40-
value: {
41-
stringValue: expect.any(String),
51+
timestamp: expect.any(Number),
52+
level: 'info',
53+
severity_number: 10,
54+
trace_id: expect.any(String),
55+
body: 'console.log 123 false',
56+
attributes: {
57+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
58+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
59+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
4260
},
4361
},
44-
],
45-
timeUnixNano: expect.any(String),
46-
traceId: expect.any(String),
47-
severityNumber: 1,
48-
},
49-
]);
50-
51-
expect(envelopeItems[1]).toEqual([
52-
{
53-
type: 'otel_log',
54-
},
55-
{
56-
severityText: 'debug',
57-
body: { stringValue: 'console.debug 123 false' },
58-
attributes: [
5962
{
60-
key: 'sentry.origin',
61-
value: {
62-
stringValue: 'auto.console.logging',
63+
timestamp: expect.any(Number),
64+
level: 'info',
65+
severity_number: 9,
66+
trace_id: expect.any(String),
67+
body: 'console.info 123 false',
68+
attributes: {
69+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
70+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
71+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
6372
},
6473
},
6574
{
66-
key: 'sentry.sdk.name',
67-
value: {
68-
stringValue: 'sentry.javascript.browser',
75+
timestamp: expect.any(Number),
76+
level: 'warn',
77+
severity_number: 13,
78+
trace_id: expect.any(String),
79+
body: 'console.warn 123 false',
80+
attributes: {
81+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
82+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
83+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
6984
},
7085
},
7186
{
72-
key: 'sentry.sdk.version',
73-
value: {
74-
stringValue: expect.any(String),
75-
},
76-
},
77-
],
78-
timeUnixNano: expect.any(String),
79-
traceId: expect.any(String),
80-
severityNumber: 5,
81-
},
82-
]);
83-
84-
expect(envelopeItems[2]).toEqual([
85-
{
86-
type: 'otel_log',
87-
},
88-
{
89-
severityText: 'info',
90-
body: { stringValue: 'console.log 123 false' },
91-
attributes: [
92-
{
93-
key: 'sentry.origin',
94-
value: {
95-
stringValue: 'auto.console.logging',
96-
},
97-
},
98-
{
99-
key: 'sentry.sdk.name',
100-
value: {
101-
stringValue: 'sentry.javascript.browser',
102-
},
103-
},
104-
{
105-
key: 'sentry.sdk.version',
106-
value: {
107-
stringValue: expect.any(String),
108-
},
109-
},
110-
],
111-
timeUnixNano: expect.any(String),
112-
traceId: expect.any(String),
113-
severityNumber: 10,
114-
},
115-
]);
116-
117-
expect(envelopeItems[3]).toEqual([
118-
{
119-
type: 'otel_log',
120-
},
121-
{
122-
severityText: 'info',
123-
body: { stringValue: 'console.info 123 false' },
124-
attributes: [
125-
{
126-
key: 'sentry.origin',
127-
value: {
128-
stringValue: 'auto.console.logging',
129-
},
130-
},
131-
{
132-
key: 'sentry.sdk.name',
133-
value: {
134-
stringValue: 'sentry.javascript.browser',
135-
},
136-
},
137-
{
138-
key: 'sentry.sdk.version',
139-
value: {
140-
stringValue: expect.any(String),
141-
},
142-
},
143-
],
144-
timeUnixNano: expect.any(String),
145-
traceId: expect.any(String),
146-
severityNumber: 9,
147-
},
148-
]);
149-
150-
expect(envelopeItems[4]).toEqual([
151-
{
152-
type: 'otel_log',
153-
},
154-
{
155-
severityText: 'warn',
156-
body: { stringValue: 'console.warn 123 false' },
157-
attributes: [
158-
{
159-
key: 'sentry.origin',
160-
value: {
161-
stringValue: 'auto.console.logging',
162-
},
163-
},
164-
{
165-
key: 'sentry.sdk.name',
166-
value: {
167-
stringValue: 'sentry.javascript.browser',
168-
},
169-
},
170-
{
171-
key: 'sentry.sdk.version',
172-
value: {
173-
stringValue: expect.any(String),
174-
},
175-
},
176-
],
177-
timeUnixNano: expect.any(String),
178-
traceId: expect.any(String),
179-
severityNumber: 13,
180-
},
181-
]);
182-
183-
expect(envelopeItems[5]).toEqual([
184-
{
185-
type: 'otel_log',
186-
},
187-
{
188-
severityText: 'error',
189-
body: { stringValue: 'console.error 123 false' },
190-
attributes: [
191-
{
192-
key: 'sentry.origin',
193-
value: {
194-
stringValue: 'auto.console.logging',
195-
},
196-
},
197-
{
198-
key: 'sentry.sdk.name',
199-
value: {
200-
stringValue: 'sentry.javascript.browser',
201-
},
202-
},
203-
{
204-
key: 'sentry.sdk.version',
205-
value: {
206-
stringValue: expect.any(String),
207-
},
208-
},
209-
],
210-
timeUnixNano: expect.any(String),
211-
traceId: expect.any(String),
212-
severityNumber: 17,
213-
},
214-
]);
215-
216-
expect(envelopeItems[6]).toEqual([
217-
{
218-
type: 'otel_log',
219-
},
220-
{
221-
severityText: 'error',
222-
body: { stringValue: 'Assertion failed: console.assert 123 false' },
223-
attributes: [
224-
{
225-
key: 'sentry.origin',
226-
value: {
227-
stringValue: 'auto.console.logging',
87+
timestamp: expect.any(Number),
88+
level: 'error',
89+
severity_number: 17,
90+
trace_id: expect.any(String),
91+
body: 'console.error 123 false',
92+
attributes: {
93+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
94+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
95+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
22896
},
22997
},
23098
{
231-
key: 'sentry.sdk.name',
232-
value: {
233-
stringValue: 'sentry.javascript.browser',
99+
timestamp: expect.any(Number),
100+
level: 'error',
101+
severity_number: 17,
102+
trace_id: expect.any(String),
103+
body: 'Assertion failed: console.assert 123 false',
104+
attributes: {
105+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
106+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
107+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
234108
},
235109
},
236110
{
237-
key: 'sentry.sdk.version',
238-
value: {
239-
stringValue: expect.any(String),
111+
timestamp: expect.any(Number),
112+
level: 'info',
113+
severity_number: 10,
114+
trace_id: expect.any(String),
115+
body: '',
116+
attributes: {
117+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
118+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
119+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
240120
},
241121
},
242122
],
243-
timeUnixNano: expect.any(String),
244-
traceId: expect.any(String),
245-
severityNumber: 17,
246123
},
247124
]);
248125
});

0 commit comments

Comments
 (0)