@@ -359,13 +359,13 @@ export class Span implements SpanInterface, SpanContext {
359359 */
360360 public getTraceContext ( ) : object {
361361 return dropUndefinedKeys ( {
362- data : this . data ,
362+ data : Object . keys ( this . data ) . length > 0 ? this . data : undefined ,
363363 description : this . description ,
364364 op : this . op ,
365365 parent_span_id : this . _parentSpanId ,
366366 span_id : this . _spanId ,
367367 status : this . tags . status ,
368- tags : this . tags ,
368+ tags : Object . keys ( this . tags ) . length > 0 ? this . tags : undefined ,
369369 trace_id : this . _traceId ,
370370 } ) ;
371371 }
@@ -375,14 +375,14 @@ export class Span implements SpanInterface, SpanContext {
375375 */
376376 public toJSON ( ) : object {
377377 return dropUndefinedKeys ( {
378- data : this . data ,
378+ data : Object . keys ( this . data ) . length > 0 ? this . data : undefined ,
379379 description : this . description ,
380380 op : this . op ,
381381 parent_span_id : this . _parentSpanId ,
382382 sampled : this . sampled ,
383383 span_id : this . _spanId ,
384384 start_timestamp : this . startTimestamp ,
385- tags : this . tags ,
385+ tags : Object . keys ( this . tags ) . length > 0 ? this . tags : undefined ,
386386 timestamp : this . timestamp ,
387387 trace_id : this . _traceId ,
388388 transaction : this . transaction ,
0 commit comments