Skip to content

Commit 7692174

Browse files
committed
feat(core): Deprecate Span.status
1 parent 0bcf0fb commit 7692174

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
@@ -66,11 +66,6 @@ export class Span implements SpanInterface {
6666
*/
6767
public parentSpanId?: string;
6868

69-
/**
70-
* Internal keeper of the status
71-
*/
72-
public status?: SpanStatusType | string;
73-
7469
/**
7570
* @inheritDoc
7671
*/
@@ -125,6 +120,8 @@ export class Span implements SpanInterface {
125120
protected _startTime: number;
126121
/** Epoch timestamp in seconds when the span ended. */
127122
protected _endTime?: number;
123+
/** Internal keeper of the status */
124+
protected _status?: SpanStatusType | string;
128125

129126
private _logMessage?: string;
130127

@@ -161,7 +158,7 @@ export class Span implements SpanInterface {
161158
this.op = spanContext.op;
162159
}
163160
if (spanContext.status) {
164-
this.status = spanContext.status;
161+
this._status = spanContext.status;
165162
}
166163
if (spanContext.endTimestamp) {
167164
this._endTime = spanContext.endTimestamp;
@@ -299,6 +296,24 @@ export class Span implements SpanInterface {
299296
this._endTime = endTime;
300297
}
301298

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

304319
/** @inheritdoc */
@@ -398,7 +413,7 @@ export class Span implements SpanInterface {
398413
* @inheritDoc
399414
*/
400415
public setStatus(value: SpanStatusType): this {
401-
this.status = value;
416+
this._status = value;
402417
return this;
403418
}
404419

@@ -438,7 +453,7 @@ export class Span implements SpanInterface {
438453
* @inheritDoc
439454
*/
440455
public isSuccess(): boolean {
441-
return this.status === 'ok';
456+
return this._status === 'ok';
442457
}
443458

444459
/**
@@ -496,7 +511,7 @@ export class Span implements SpanInterface {
496511
sampled: this._sampled,
497512
spanId: this._spanId,
498513
startTimestamp: this._startTime,
499-
status: this.status,
514+
status: this._status,
500515
// eslint-disable-next-line deprecation/deprecation
501516
tags: this.tags,
502517
traceId: this._traceId,
@@ -519,7 +534,7 @@ export class Span implements SpanInterface {
519534
this._sampled = spanContext.sampled;
520535
this._spanId = spanContext.spanId || this._spanId;
521536
this._startTime = spanContext.startTimestamp || this._startTime;
522-
this.status = spanContext.status;
537+
this._status = spanContext.status;
523538
// eslint-disable-next-line deprecation/deprecation
524539
this.tags = spanContext.tags || {};
525540
this._traceId = spanContext.traceId || this._traceId;
@@ -552,7 +567,7 @@ export class Span implements SpanInterface {
552567
parent_span_id: this.parentSpanId,
553568
span_id: this._spanId,
554569
start_timestamp: this._startTime,
555-
status: this.status,
570+
status: this._status,
556571
// eslint-disable-next-line deprecation/deprecation
557572
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
558573
timestamp: this._endTime,

0 commit comments

Comments
 (0)