Skip to content

Commit 15d55ad

Browse files
committed
feat(core): Deprecate Span.isSuccess in favor of reading span status
1 parent e50cc8a commit 15d55ad

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

MIGRATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ In v8, the Span class is heavily reworked. The following properties & methods ar
204204
- `span.instrumenter` This field was removed and will be replaced internally.
205205
- `span.transaction`: Use `getRootSpan` utility function instead.
206206
- `span.spanRecorder`: Span recording will be handled internally by the SDK.
207+
- `span.isSuccess`: Use `spanToJSON(span).status === 'ok'` instead.
207208
- `transaction.setMetadata()`: Use attributes instead, or set data on the scope.
208209
- `transaction.metadata`: Use attributes instead, or set data on the scope.
209210
- `transaction.setContext()`: Set context on the surrounding scope instead.

docs/v8-new-performance-apis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ below to see which things used to exist, and how they can/should be mapped going
6262
| `setHttpStatus()` | ??? TODO |
6363
| `setName()` | `updateName()` |
6464
| `startChild()` | Call `Sentry.startSpan()` independently |
65-
| `isSuccess()` | Removed (TODO) |
65+
| `isSuccess()` | `spanToJSON(span).status === 'ok'` |
6666
| `toTraceparent()` | `spanToTraceHeader(span)` |
6767
| `toContext()` | Removed |
6868
| `updateWithContext()` | Removed |

packages/core/src/tracing/span.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ export class Span implements SpanInterface {
442442

443443
/**
444444
* @inheritDoc
445+
*
446+
* @deprecated Use `spanToJSON(span).status === 'ok'` instead.
445447
*/
446448
public isSuccess(): boolean {
447449
return this.status === 'ok';

packages/tracing/test/span.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,29 @@ describe('Span', () => {
106106
expect(span.data['http.response.status_code']).toBe(404);
107107
});
108108

109+
// TODO (v8): Remove
109110
test('isSuccess', () => {
110111
const span = new Span({});
111112
expect(span.isSuccess()).toBe(false);
113+
expect(spanToJSON(span).status).not.toBe('ok');
112114
span.setHttpStatus(200);
113115
expect(span.isSuccess()).toBe(true);
116+
expect(spanToJSON(span).status).toBe('ok');
114117
span.setStatus('permission_denied');
115118
expect(span.isSuccess()).toBe(false);
119+
expect(spanToJSON(span).status).not.toBe('ok');
116120
span.setHttpStatus(0);
117121
expect(span.isSuccess()).toBe(false);
122+
expect(spanToJSON(span).status).not.toBe('ok');
118123
span.setHttpStatus(-1);
119124
expect(span.isSuccess()).toBe(false);
125+
expect(spanToJSON(span).status).not.toBe('ok');
120126
span.setHttpStatus(99);
121127
expect(span.isSuccess()).toBe(false);
128+
expect(spanToJSON(span).status).not.toBe('ok');
122129
span.setHttpStatus(100);
123130
expect(span.isSuccess()).toBe(true);
131+
expect(spanToJSON(span).status).toBe('ok');
124132
});
125133
});
126134

packages/types/src/span.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ export interface Span extends SpanContext {
320320

321321
/**
322322
* Determines whether span was successful (HTTP200)
323+
*
324+
* @deprecated Use `spanToJSON(span).status === 'ok'` instead.
323325
*/
324326
isSuccess(): boolean;
325327

0 commit comments

Comments
 (0)