@@ -44,9 +44,10 @@ public class SpanContext implements JsonUnknown, JsonSerializable {
4444 /** A map or list of tags for this event. Each tag must be less than 200 characters. */
4545 protected @ NotNull Map <String , @ NotNull String > tags = new ConcurrentHashMap <>();
4646
47- /** Describes the status of the Transaction. */
4847 protected @ Nullable String origin = DEFAULT_ORIGIN ;
4948
49+ protected @ NotNull Map <String , Object > data = new ConcurrentHashMap <>();
50+
5051 private @ Nullable Map <String , Object > unknown ;
5152
5253 private @ NotNull Instrumenter instrumenter = Instrumenter .SENTRY ;
@@ -73,7 +74,7 @@ public SpanContext(
7374 final @ NotNull String operation ,
7475 final @ Nullable SpanId parentSpanId ,
7576 final @ Nullable TracesSamplingDecision samplingDecision ) {
76- this (traceId , spanId , parentSpanId , operation , null , samplingDecision , null , DEFAULT_ORIGIN );
77+ this (traceId , spanId , parentSpanId , operation , null , samplingDecision , null , "manual" );
7778 }
7879
7980 @ ApiStatus .Internal
@@ -230,6 +231,14 @@ public void setInstrumenter(final @NotNull Instrumenter instrumenter) {
230231 return baggage ;
231232 }
232233
234+ public @ NotNull Map <String , Object > getData () {
235+ return data ;
236+ }
237+
238+ public void setData (final @ NotNull String key , final @ NotNull Object value ) {
239+ data .put (key , value );
240+ }
241+
233242 @ ApiStatus .Internal
234243 public SpanContext copyForChild (
235244 final @ NotNull String operation ,
@@ -275,6 +284,7 @@ public static final class JsonKeys {
275284 public static final String STATUS = "status" ;
276285 public static final String TAGS = "tags" ;
277286 public static final String ORIGIN = "origin" ;
287+ public static final String DATA = "data" ;
278288 }
279289
280290 @ Override
@@ -302,6 +312,9 @@ public void serialize(final @NotNull ObjectWriter writer, final @NotNull ILogger
302312 if (!tags .isEmpty ()) {
303313 writer .name (JsonKeys .TAGS ).value (logger , tags );
304314 }
315+ if (!data .isEmpty ()) {
316+ writer .name (JsonKeys .DATA ).value (logger , data );
317+ }
305318 if (unknown != null ) {
306319 for (String key : unknown .keySet ()) {
307320 Object value = unknown .get (key );
@@ -336,6 +349,7 @@ public static final class Deserializer implements JsonDeserializer<SpanContext>
336349 SpanStatus status = null ;
337350 String origin = null ;
338351 Map <String , String > tags = null ;
352+ Map <String , Object > data = null ;
339353
340354 Map <String , Object > unknown = null ;
341355 while (reader .peek () == JsonToken .NAME ) {
@@ -367,6 +381,9 @@ public static final class Deserializer implements JsonDeserializer<SpanContext>
367381 CollectionUtils .newConcurrentHashMap (
368382 (Map <String , String >) reader .nextObjectOrNull ());
369383 break ;
384+ case JsonKeys .DATA :
385+ data = (Map <String , Object >) reader .nextObjectOrNull ();
386+ break ;
370387 default :
371388 if (unknown == null ) {
372389 unknown = new ConcurrentHashMap <>();
@@ -404,9 +421,15 @@ public static final class Deserializer implements JsonDeserializer<SpanContext>
404421 spanContext .setDescription (description );
405422 spanContext .setStatus (status );
406423 spanContext .setOrigin (origin );
424+
407425 if (tags != null ) {
408426 spanContext .tags = tags ;
409427 }
428+
429+ if (data != null ) {
430+ spanContext .data = data ;
431+ }
432+
410433 spanContext .setUnknown (unknown );
411434 reader .endObject ();
412435 return spanContext ;
0 commit comments