@@ -20,6 +20,7 @@ import {
2020 TRACE_FLAG_NONE ,
2121 TRACE_FLAG_SAMPLED ,
2222 spanTimeInputToSeconds ,
23+ spanToJSON ,
2324 spanToTraceContext ,
2425 spanToTraceHeader ,
2526} from '../utils/spanUtils' ;
@@ -84,11 +85,6 @@ export class Span implements SpanInterface {
8485 */
8586 public op ?: string ;
8687
87- /**
88- * @inheritDoc
89- */
90- public description ?: string ;
91-
9288 /**
9389 * @inheritDoc
9490 */
@@ -128,6 +124,7 @@ export class Span implements SpanInterface {
128124 protected _traceId : string ;
129125 protected _spanId : string ;
130126 protected _sampled : boolean | undefined ;
127+ protected _name ?: string ;
131128
132129 /**
133130 * You should never call the constructor manually, always use `Sentry.startTransaction()`
@@ -145,6 +142,8 @@ export class Span implements SpanInterface {
145142 this . attributes = spanContext . attributes || { } ;
146143 this . instrumenter = spanContext . instrumenter || 'sentry' ;
147144 this . origin = spanContext . origin || 'manual' ;
145+ // eslint-disable-next-line deprecation/deprecation
146+ this . _name = spanContext . name || spanContext . description ;
148147
149148 if ( spanContext . parentSpanId ) {
150149 this . parentSpanId = spanContext . parentSpanId ;
@@ -156,12 +155,6 @@ export class Span implements SpanInterface {
156155 if ( spanContext . op ) {
157156 this . op = spanContext . op ;
158157 }
159- if ( spanContext . description ) {
160- this . description = spanContext . description ;
161- }
162- if ( spanContext . name ) {
163- this . description = spanContext . name ;
164- }
165158 if ( spanContext . status ) {
166159 this . status = spanContext . status ;
167160 }
@@ -170,20 +163,40 @@ export class Span implements SpanInterface {
170163 }
171164 }
172165
173- // This conflicts with another eslint rule :(
166+ // This rule conflicts with another rule :(
174167 /* eslint-disable @typescript-eslint/member-ordering */
175168
176- /** An alias for `description` of the Span. */
169+ /**
170+ * An alias for `description` of the Span.
171+ * @deprecated Use `spanToJSON(span).description` instead.
172+ */
177173 public get name ( ) : string {
178- return this . description || '' ;
174+ return this . _name || '' ;
179175 }
180176 /**
181177 * Update the name of the span.
178+ * @deprecated Use `spanToJSON(span).description` instead.
182179 */
183180 public set name ( name : string ) {
184181 this . updateName ( name ) ;
185182 }
186183
184+ /**
185+ * Get the description of the Span.
186+ * @deprecated Use `spanToJSON(span).description` instead.
187+ */
188+ public get description ( ) : string | undefined {
189+ return this . _name ;
190+ }
191+
192+ /**
193+ * Get the description of the Span.
194+ * @deprecated Use `spanToJSON(span).description` instead.
195+ */
196+ public set description ( description : string | undefined ) {
197+ this . _name = description ;
198+ }
199+
187200 /**
188201 * The ID of the trace.
189202 * @deprecated Use `spanContext().traceId` instead.
@@ -269,7 +282,7 @@ export class Span implements SpanInterface {
269282
270283 if ( DEBUG_BUILD && childSpan . transaction ) {
271284 const opStr = ( spanContext && spanContext . op ) || '< unknown op >' ;
272- const nameStr = childSpan . transaction . name || '< unknown name >' ;
285+ const nameStr = spanToJSON ( childSpan ) . description || '< unknown name >' ;
273286 const idStr = childSpan . transaction . spanContext ( ) . spanId ;
274287
275288 const logMessage = `[Tracing] Starting '${ opStr } ' span on transaction '${ nameStr } ' (${ idStr } ).` ;
@@ -342,7 +355,7 @@ export class Span implements SpanInterface {
342355 * @inheritDoc
343356 */
344357 public updateName ( name : string ) : this {
345- this . description = name ;
358+ this . _name = name ;
346359 return this ;
347360 }
348361
@@ -392,7 +405,7 @@ export class Span implements SpanInterface {
392405 public toContext ( ) : SpanContext {
393406 return dropUndefinedKeys ( {
394407 data : this . _getData ( ) ,
395- description : this . description ,
408+ description : this . _name ,
396409 endTimestamp : this . endTimestamp ,
397410 op : this . op ,
398411 parentSpanId : this . parentSpanId ,
@@ -410,7 +423,8 @@ export class Span implements SpanInterface {
410423 */
411424 public updateWithContext ( spanContext : SpanContext ) : this {
412425 this . data = spanContext . data || { } ;
413- this . description = spanContext . description ;
426+ // eslint-disable-next-line deprecation/deprecation
427+ this . _name = spanContext . name || spanContext . description ;
414428 this . endTimestamp = spanContext . endTimestamp ;
415429 this . op = spanContext . op ;
416430 this . parentSpanId = spanContext . parentSpanId ;
@@ -437,7 +451,7 @@ export class Span implements SpanInterface {
437451 public getSpanJSON ( ) : SpanJSON {
438452 return dropUndefinedKeys ( {
439453 data : this . _getData ( ) ,
440- description : this . description ,
454+ description : this . _name ,
441455 op : this . op ,
442456 parent_span_id : this . parentSpanId ,
443457 span_id : this . _spanId ,
0 commit comments