Skip to content

Commit 09a7a37

Browse files
committed
feat(core): Deprecate Span.status
1 parent 9c6d501 commit 09a7a37

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

packages/core/src/tracing/span.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ export class Span implements SpanInterface {
6767
*/
6868
public parentSpanId?: string;
6969

70-
/**
71-
* Internal keeper of the status
72-
*/
73-
public status?: SpanStatusType | string;
74-
7570
/**
7671
* @inheritDoc
7772
*/
@@ -128,6 +123,8 @@ export class Span implements SpanInterface {
128123
protected _startTime: number;
129124
/** Epoch timestamp in seconds when the span ended. */
130125
protected _endTime?: number;
126+
/** Internal keeper of the status */
127+
protected _status?: SpanStatusType | string;
131128

132129
private _logMessage?: string;
133130

@@ -164,7 +161,7 @@ export class Span implements SpanInterface {
164161
this.op = spanContext.op;
165162
}
166163
if (spanContext.status) {
167-
this.status = spanContext.status;
164+
this._status = spanContext.status;
168165
}
169166
if (spanContext.endTimestamp) {
170167
this._endTime = spanContext.endTimestamp;
@@ -302,6 +299,24 @@ export class Span implements SpanInterface {
302299
this._endTime = endTime;
303300
}
304301

302+
/**
303+
* The status of the span.
304+
*
305+
* @deprecated Use `spanToJSON().status` instead to get the status.
306+
*/
307+
public get status(): SpanStatusType | string | undefined {
308+
return this._status;
309+
}
310+
311+
/**
312+
* The status of the span.
313+
*
314+
* @deprecated Use `.setStatus()` instead to set or update the status.
315+
*/
316+
public set status(status: SpanStatusType | string | undefined) {
317+
this._status = status;
318+
}
319+
305320
/* eslint-enable @typescript-eslint/member-ordering */
306321

307322
/** @inheritdoc */
@@ -404,7 +419,7 @@ export class Span implements SpanInterface {
404419
* @inheritDoc
405420
*/
406421
public setStatus(value: SpanStatusType): this {
407-
this.status = value;
422+
this._status = value;
408423
return this;
409424
}
410425

@@ -444,7 +459,7 @@ export class Span implements SpanInterface {
444459
* @inheritDoc
445460
*/
446461
public isSuccess(): boolean {
447-
return this.status === 'ok';
462+
return this._status === 'ok';
448463
}
449464

450465
/**
@@ -502,7 +517,7 @@ export class Span implements SpanInterface {
502517
sampled: this._sampled,
503518
spanId: this._spanId,
504519
startTimestamp: this._startTime,
505-
status: this.status,
520+
status: this._status,
506521
// eslint-disable-next-line deprecation/deprecation
507522
tags: this.tags,
508523
traceId: this._traceId,
@@ -525,7 +540,7 @@ export class Span implements SpanInterface {
525540
this._sampled = spanContext.sampled;
526541
this._spanId = spanContext.spanId || this._spanId;
527542
this._startTime = spanContext.startTimestamp || this._startTime;
528-
this.status = spanContext.status;
543+
this._status = spanContext.status;
529544
// eslint-disable-next-line deprecation/deprecation
530545
this.tags = spanContext.tags || {};
531546
this._traceId = spanContext.traceId || this._traceId;
@@ -558,7 +573,7 @@ export class Span implements SpanInterface {
558573
parent_span_id: this.parentSpanId,
559574
span_id: this._spanId,
560575
start_timestamp: this._startTime,
561-
status: this.status,
576+
status: this._status,
562577
// eslint-disable-next-line deprecation/deprecation
563578
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
564579
timestamp: this._endTime,

0 commit comments

Comments
 (0)