11import type {
2+ SentrySpanArguments ,
23 Span ,
34 SpanAttributeValue ,
45 SpanAttributes ,
5- SpanContext ,
66 SpanContextData ,
77 SpanJSON ,
88 SpanOrigin ,
@@ -32,13 +32,6 @@ import {
3232 * Span contains all data about a span
3333 */
3434export class SentrySpan implements Span {
35- /**
36- * Data for the span.
37- * @deprecated Use `spanToJSON(span).atttributes` instead.
38- */
39- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40- public data : { [ key : string ] : any } ;
41-
4235 /**
4336 * @inheritDoc
4437 * @deprecated Use top level `Sentry.getRootSpan()` instead
@@ -66,12 +59,10 @@ export class SentrySpan implements Span {
6659 * @hideconstructor
6760 * @hidden
6861 */
69- public constructor ( spanContext : SpanContext = { } ) {
62+ public constructor ( spanContext : SentrySpanArguments = { } ) {
7063 this . _traceId = spanContext . traceId || uuid4 ( ) ;
7164 this . _spanId = spanContext . spanId || uuid4 ( ) . substring ( 16 ) ;
7265 this . _startTime = spanContext . startTimestamp || timestampInSeconds ( ) ;
73- // eslint-disable-next-line deprecation/deprecation
74- this . data = spanContext . data ? { ...spanContext . data } : { } ;
7566
7667 this . _attributes = { } ;
7768 this . setAttributes ( {
@@ -164,7 +155,10 @@ export class SentrySpan implements Span {
164155 * @deprecated Use `startSpan()`, `startSpanManual()` or `startInactiveSpan()` instead.
165156 */
166157 public startChild (
167- spanContext : Pick < SpanContext , Exclude < keyof SpanContext , 'sampled' | 'traceId' | 'parentSpanId' > > = { } ,
158+ spanContext : Pick <
159+ SentrySpanArguments ,
160+ Exclude < keyof SentrySpanArguments , 'sampled' | 'traceId' | 'parentSpanId' >
161+ > = { } ,
168162 ) : Span {
169163 const childSpan = new SentrySpan ( {
170164 ...spanContext ,
@@ -206,19 +200,6 @@ export class SentrySpan implements Span {
206200 return childSpan ;
207201 }
208202
209- /**
210- * Sets the data attribute on the current span
211- * @param key Data key
212- * @param value Data value
213- * @deprecated Use `setAttribute()` instead.
214- */
215- // eslint-disable-next-line @typescript-eslint/no-explicit-any
216- public setData ( key : string , value : any ) : this {
217- // eslint-disable-next-line deprecation/deprecation
218- this . data = { ...this . data , [ key ] : value } ;
219- return this ;
220- }
221-
222203 /** @inheritdoc */
223204 public setAttribute ( key : string , value : SpanAttributeValue | undefined ) : void {
224205 if ( value === undefined ) {
@@ -291,9 +272,9 @@ export class SentrySpan implements Span {
291272 *
292273 * @deprecated Use `spanToJSON()` or access the fields directly instead.
293274 */
294- public toContext ( ) : SpanContext {
275+ public toContext ( ) : SentrySpanArguments {
295276 return dropUndefinedKeys ( {
296- data : this . _getData ( ) ,
277+ data : this . _attributes ,
297278 name : this . _name ,
298279 endTimestamp : this . _endTime ,
299280 op : this . _attributes [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] ,
@@ -325,7 +306,7 @@ export class SentrySpan implements Span {
325306 */
326307 public getSpanJSON ( ) : SpanJSON {
327308 return dropUndefinedKeys ( {
328- data : this . _getData ( ) ,
309+ data : this . _attributes ,
329310 description : this . _name ,
330311 op : this . _attributes [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] ,
331312 parent_span_id : this . _parentSpanId ,
@@ -352,37 +333,6 @@ export class SentrySpan implements Span {
352333 return this . getSpanJSON ( ) ;
353334 }
354335
355- /**
356- * Get the merged data for this span.
357- * For now, this combines `data` and `attributes` together,
358- * until eventually we can ingest `attributes` directly.
359- */
360- private _getData ( ) :
361- | {
362- // eslint-disable-next-line @typescript-eslint/no-explicit-any
363- [ key : string ] : any ;
364- }
365- | undefined {
366- // eslint-disable-next-line deprecation/deprecation
367- const { data, _attributes : attributes } = this ;
368-
369- const hasData = Object . keys ( data ) . length > 0 ;
370- const hasAttributes = Object . keys ( attributes ) . length > 0 ;
371-
372- if ( ! hasData && ! hasAttributes ) {
373- return undefined ;
374- }
375-
376- if ( hasData && hasAttributes ) {
377- return {
378- ...data ,
379- ...attributes ,
380- } ;
381- }
382-
383- return hasData ? data : attributes ;
384- }
385-
386336 /** Emit `spanEnd` when the span is ended. */
387337 private _onSpanEnded ( ) : void {
388338 const client = getClient ( ) ;
0 commit comments