Skip to content

Commit a360faa

Browse files
committed
fixes
1 parent b4a39c4 commit a360faa

15 files changed

Lines changed: 62 additions & 17 deletions

packages/browser/src/tracing/backgroundtab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function registerBackgroundTabDetection(): void {
2727

2828
// We should not set status if it is already set, this prevent important statuses like
2929
// error or data loss from being overwritten on transaction.
30-
if (!status) {
30+
if (status === 'ok') {
3131
rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message: cancelledStatus });
3232
}
3333

packages/core/src/tracing/trace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function startSpan<T>(options: StartSpanOptions, callback: (span: Span) =
9191
() => {
9292
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
9393
const { status } = spanToJSON(activeSpan);
94-
if (activeSpan.isRecording() && (!status || status === 'ok')) {
94+
if (activeSpan.isRecording() && status === 'ok') {
9595
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
9696
}
9797
},
@@ -157,7 +157,7 @@ export function startSpanManual<T>(options: StartSpanOptions, callback: (span: S
157157
() => {
158158
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
159159
const { status } = spanToJSON(activeSpan);
160-
if (activeSpan.isRecording() && (!status || status === 'ok')) {
160+
if (activeSpan.isRecording() && status === 'ok') {
161161
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
162162
}
163163
},

packages/core/test/lib/client.test.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ describe('Client', () => {
991991
start_timestamp: 1591603196.637835,
992992
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
993993
data: {},
994+
status: 'ok',
994995
},
995996
{
996997
description: 'first-contentful-paint',
@@ -1001,6 +1002,7 @@ describe('Client', () => {
10011002
start_timestamp: 1591603196.637835,
10021003
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
10031004
data: {},
1005+
status: 'ok',
10041006
},
10051007
],
10061008
start_timestamp: 1591603196.614865,
@@ -1063,13 +1065,15 @@ describe('Client', () => {
10631065
start_timestamp: 1591603196.637835,
10641066
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
10651067
data: {},
1068+
status: 'ok',
10661069
},
10671070
{
10681071
description: 'second span',
10691072
span_id: 'aa554c1f506b0783',
10701073
start_timestamp: 1591603196.637835,
10711074
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
10721075
data: {},
1076+
status: 'ok',
10731077
},
10741078
],
10751079
};
@@ -1098,13 +1102,15 @@ describe('Client', () => {
10981102
start_timestamp: 1591603196.637835,
10991103
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11001104
data: {},
1105+
status: 'ok',
11011106
},
11021107
{
11031108
description: 'second span',
11041109
span_id: 'aa554c1f506b0783',
11051110
start_timestamp: 1591603196.637835,
11061111
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11071112
data: {},
1113+
status: 'ok',
11081114
},
11091115
],
11101116
};
@@ -1139,6 +1145,7 @@ describe('Client', () => {
11391145
start_timestamp: 1591603196.637835,
11401146
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11411147
data: {},
1148+
status: 'ok',
11421149
},
11431150
{
11441151
description: 'second span',
@@ -1147,6 +1154,7 @@ describe('Client', () => {
11471154
start_timestamp: 1591603196.637835,
11481155
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11491156
data: {},
1157+
status: 'ok',
11501158
},
11511159
{
11521160
description: 'third span',
@@ -1155,6 +1163,7 @@ describe('Client', () => {
11551163
start_timestamp: 1591603196.637835,
11561164
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11571165
data: {},
1166+
status: 'ok',
11581167
},
11591168
],
11601169
};
@@ -1169,6 +1178,7 @@ describe('Client', () => {
11691178
start_timestamp: 1591603196.637835,
11701179
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11711180
data: {},
1181+
status: 'ok',
11721182
},
11731183
{
11741184
description: 'third span',
@@ -1177,6 +1187,7 @@ describe('Client', () => {
11771187
start_timestamp: 1591603196.637835,
11781188
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
11791189
data: {},
1190+
status: 'ok',
11801191
},
11811192
]);
11821193
expect(recordDroppedEventSpy).toBeCalledWith('before_send', 'span', 1);
@@ -1203,6 +1214,7 @@ describe('Client', () => {
12031214
trace: {
12041215
span_id: 'root-span-id',
12051216
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
1217+
status: 'ok',
12061218
},
12071219
},
12081220
transaction: 'root span',
@@ -1215,6 +1227,7 @@ describe('Client', () => {
12151227
start_timestamp: 1591603196.637835,
12161228
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
12171229
data: {},
1230+
status: 'ok',
12181231
},
12191232
{
12201233
description: 'second span',
@@ -1224,6 +1237,7 @@ describe('Client', () => {
12241237
start_timestamp: 1591603196.637835,
12251238
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
12261239
data: {},
1240+
status: 'ok',
12271241
},
12281242
{
12291243
description: 'third span',
@@ -1233,6 +1247,7 @@ describe('Client', () => {
12331247
start_timestamp: 1591603196.637835,
12341248
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
12351249
data: {},
1250+
status: 'ok',
12361251
},
12371252
],
12381253
};
@@ -1248,6 +1263,7 @@ describe('Client', () => {
12481263
start_timestamp: 1591603196.637835,
12491264
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
12501265
data: {},
1266+
status: 'ok',
12511267
},
12521268
]);
12531269
expect(recordDroppedEventSpy).toBeCalledWith('before_send', 'span', 2);
@@ -1276,6 +1292,7 @@ describe('Client', () => {
12761292
],
12771293
contexts: {
12781294
trace: {
1295+
status: 'ok',
12791296
data: {
12801297
modified: 'false',
12811298
dropMe: 'true',
@@ -1314,6 +1331,7 @@ describe('Client', () => {
13141331
},
13151332
span_id: '9e15bf99fbe4bc80',
13161333
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
1334+
status: 'ok',
13171335
},
13181336
app: {
13191337
data: {
@@ -1352,9 +1370,9 @@ describe('Client', () => {
13521370
transaction: '/dogs/are/great',
13531371
type: 'transaction',
13541372
spans: [
1355-
{ span_id: 'span1', trace_id: 'trace1', start_timestamp: 1234, data: {} },
1356-
{ span_id: 'span2', trace_id: 'trace1', start_timestamp: 1234, data: {} },
1357-
{ span_id: 'span3', trace_id: 'trace1', start_timestamp: 1234, data: {} },
1373+
{ span_id: 'span1', trace_id: 'trace1', start_timestamp: 1234, data: {}, status: 'ok' },
1374+
{ span_id: 'span2', trace_id: 'trace1', start_timestamp: 1234, data: {}, status: 'ok' },
1375+
{ span_id: 'span3', trace_id: 'trace1', start_timestamp: 1234, data: {}, status: 'ok' },
13581376
],
13591377
});
13601378

@@ -1384,13 +1402,15 @@ describe('Client', () => {
13841402
start_timestamp: 1591603196.637835,
13851403
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
13861404
data: {},
1405+
status: 'ok',
13871406
},
13881407
{
13891408
description: 'second span',
13901409
span_id: 'aa554c1f506b0783',
13911410
start_timestamp: 1591603196.637835,
13921411
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
13931412
data: {},
1413+
status: 'ok',
13941414
},
13951415
],
13961416
};
@@ -1461,13 +1481,15 @@ describe('Client', () => {
14611481
start_timestamp: 1591603196.637835,
14621482
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
14631483
data: {},
1484+
status: 'ok',
14641485
},
14651486
{
14661487
description: 'second span',
14671488
span_id: 'aa554c1f506b0783',
14681489
start_timestamp: 1591603196.637835,
14691490
trace_id: '86f39e84263a4de99c326acab3bfe3bd',
14701491
data: {},
1492+
status: 'ok',
14711493
},
14721494
],
14731495
};

packages/core/test/lib/envelope.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ describe('createSpanEnvelope', () => {
133133
start_timestamp: 1,
134134
timestamp: 2,
135135
trace_id: expect.stringMatching(/^[0-9a-f]{32}$/),
136+
status: 'ok',
136137
});
137138
});
138139

@@ -223,6 +224,7 @@ describe('createSpanEnvelope', () => {
223224
start_timestamp: 1,
224225
timestamp: 2,
225226
trace_id: expect.stringMatching(/^[0-9a-f]{32}$/),
227+
status: 'ok',
226228
});
227229
});
228230

@@ -258,6 +260,7 @@ describe('createSpanEnvelope', () => {
258260
start_timestamp: 1,
259261
timestamp: 2,
260262
trace_id: expect.stringMatching(/^[0-9a-f]{32}$/),
263+
status: 'ok',
261264
});
262265
});
263266
});

packages/core/test/lib/tracing/errors.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ describe('registerErrorHandlers()', () => {
4343
registerSpanErrorInstrumentation();
4444

4545
const transaction = startInactiveSpan({ name: 'test' })!;
46-
expect(spanToJSON(transaction).status).toBe(undefined);
46+
expect(spanToJSON(transaction).status).toBe('ok');
4747

4848
mockErrorCallback({} as HandlerDataError);
49-
expect(spanToJSON(transaction).status).toBe(undefined);
49+
expect(spanToJSON(transaction).status).toBe('ok');
5050

5151
mockUnhandledRejectionCallback({});
52-
expect(spanToJSON(transaction).status).toBe(undefined);
52+
expect(spanToJSON(transaction).status).toBe('ok');
5353

5454
transaction.end();
5555
});

packages/core/test/lib/tracing/sentryNonRecordingSpan.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('SentryNonRecordingSpan', () => {
2121
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
2222
data: {},
2323
start_timestamp: 0,
24+
status: 'ok',
2425
});
2526

2627
// Ensure all methods work
@@ -37,6 +38,7 @@ describe('SentryNonRecordingSpan', () => {
3738
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
3839
data: {},
3940
start_timestamp: 0,
41+
status: 'ok',
4042
});
4143
});
4244
});

packages/core/test/lib/tracing/sentrySpan.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ describe('SentrySpan', () => {
355355
origin: 'manual',
356356
span_id: expect.stringMatching(/^[a-f0-9]{16}$/),
357357
trace_id: expect.stringMatching(/^[a-f0-9]{32}$/),
358+
status: 'ok',
358359
},
359360
},
360361
sdkProcessingMetadata: {

packages/core/test/lib/tracing/trace.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describe('startSpan', () => {
105105
expect(_span).toBeDefined();
106106

107107
expect(spanToJSON(_span!).description).toEqual('GET users/[id]');
108-
expect(spanToJSON(_span!).status).toEqual(isError ? 'internal_error' : undefined);
108+
expect(spanToJSON(_span!).status).toEqual(isError ? 'internal_error' : 'ok');
109109
});
110110

111111
it('allows for transaction to be mutated', async () => {
@@ -148,7 +148,7 @@ describe('startSpan', () => {
148148
expect(spans).toHaveLength(2);
149149
expect(spanToJSON(spans[1]!).description).toEqual('SELECT * from users');
150150
expect(spanToJSON(spans[1]!).parent_span_id).toEqual(_span!.spanContext().spanId);
151-
expect(spanToJSON(spans[1]!).status).toEqual(isError ? 'internal_error' : undefined);
151+
expect(spanToJSON(spans[1]!).status).toEqual(isError ? 'internal_error' : 'ok');
152152
});
153153

154154
it('allows for span to be mutated', async () => {
@@ -207,7 +207,7 @@ describe('startSpan', () => {
207207
description: 'GET users/[id]',
208208
span_id: expect.stringMatching(/[a-f0-9]{16}/),
209209
start_timestamp: expect.any(Number),
210-
status: isError ? 'internal_error' : undefined,
210+
status: isError ? 'internal_error' : 'ok',
211211
timestamp: expect.any(Number),
212212
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
213213
});
@@ -573,6 +573,7 @@ describe('startSpan', () => {
573573
span_id: expect.stringMatching(/[a-f0-9]{16}/),
574574
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
575575
origin: 'manual',
576+
status: 'ok',
576577
},
577578
});
578579
expect(outerTransaction?.spans).toEqual([{ name: 'inner span', id: expect.any(String) }]);
@@ -598,6 +599,7 @@ describe('startSpan', () => {
598599
span_id: expect.stringMatching(/[a-f0-9]{16}/),
599600
trace_id: outerTraceId,
600601
origin: 'manual',
602+
status: 'ok',
601603
},
602604
});
603605
expect(innerTransaction?.spans).toEqual([{ name: 'inner span 2', id: expect.any(String) }]);
@@ -1212,6 +1214,7 @@ describe('startSpanManual', () => {
12121214
span_id: expect.stringMatching(/[a-f0-9]{16}/),
12131215
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
12141216
origin: 'manual',
1217+
status: 'ok',
12151218
},
12161219
});
12171220
expect(outerTransaction?.spans).toEqual([{ name: 'inner span', id: expect.any(String) }]);
@@ -1237,6 +1240,7 @@ describe('startSpanManual', () => {
12371240
span_id: expect.stringMatching(/[a-f0-9]{16}/),
12381241
trace_id: outerTraceId,
12391242
origin: 'manual',
1243+
status: 'ok',
12401244
},
12411245
});
12421246
expect(innerTransaction?.spans).toEqual([{ name: 'inner span 2', id: expect.any(String) }]);
@@ -1639,6 +1643,7 @@ describe('startInactiveSpan', () => {
16391643
span_id: expect.stringMatching(/[a-f0-9]{16}/),
16401644
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
16411645
origin: 'manual',
1646+
status: 'ok',
16421647
},
16431648
});
16441649
expect(outerTransaction?.spans).toEqual([{ name: 'inner span', id: expect.any(String) }]);
@@ -1664,6 +1669,7 @@ describe('startInactiveSpan', () => {
16641669
span_id: expect.stringMatching(/[a-f0-9]{16}/),
16651670
trace_id: outerTraceId,
16661671
origin: 'manual',
1672+
status: 'ok',
16671673
},
16681674
});
16691675
expect(innerTransaction?.spans).toEqual([]);

packages/core/test/lib/utils/spanUtils.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ describe('spanToJSON', () => {
321321
trace_id: span.spanContext().traceId,
322322
origin: 'manual',
323323
start_timestamp: span['_startTime'],
324+
status: 'ok',
324325
data: {
325326
'sentry.origin': 'manual',
326327
},
@@ -378,6 +379,7 @@ describe('spanToJSON', () => {
378379
start_timestamp: 123,
379380
description: 'test span',
380381
data: {},
382+
status: 'ok',
381383
});
382384
});
383385

@@ -730,6 +732,7 @@ describe('spanToJSON', () => {
730732
};
731733

732734
expect(spanToJSON(span as unknown as Span)).toEqual({
735+
status: 'ok',
733736
span_id: 'SPAN-1',
734737
trace_id: 'TRACE-1',
735738
start_timestamp: 0,

0 commit comments

Comments
 (0)