1313public final class SentryLogEvent implements JsonUnknown , JsonSerializable {
1414
1515 private @ NotNull SentryId traceId ;
16+ private @ Nullable SpanId spanId ;
1617 private @ NotNull Double timestamp ;
1718 private @ NotNull String body ;
1819 private @ NotNull SentryLogLevel level ;
@@ -92,10 +93,27 @@ public void setSeverityNumber(final @Nullable Integer severityNumber) {
9293 this .severityNumber = severityNumber ;
9394 }
9495
96+ public @ Nullable SpanId getSpanId () {
97+ return spanId ;
98+ }
99+
100+ public void setSpanId (final @ Nullable SpanId spanId ) {
101+ this .spanId = spanId ;
102+ }
103+
104+ public @ NotNull SentryId getTraceId () {
105+ return traceId ;
106+ }
107+
108+ public void setTraceId (final @ NotNull SentryId traceId ) {
109+ this .traceId = traceId ;
110+ }
111+
95112 // region json
96113 public static final class JsonKeys {
97114 public static final String TIMESTAMP = "timestamp" ;
98115 public static final String TRACE_ID = "trace_id" ;
116+ public static final String SPAN_ID = "span_id" ;
99117 public static final String LEVEL = "level" ;
100118 public static final String SEVERITY_NUMBER = "severity_number" ;
101119 public static final String BODY = "body" ;
@@ -109,6 +127,9 @@ public void serialize(final @NotNull ObjectWriter writer, final @NotNull ILogger
109127 writer .beginObject ();
110128 writer .name (JsonKeys .TIMESTAMP ).value (logger , doubleToBigDecimal (timestamp ));
111129 writer .name (JsonKeys .TRACE_ID ).value (logger , traceId );
130+ if (spanId != null ) {
131+ writer .name (JsonKeys .SPAN_ID ).value (logger , spanId );
132+ }
112133 writer .name (JsonKeys .BODY ).value (body );
113134 writer .name (JsonKeys .LEVEL ).value (logger , level );
114135 if (severityNumber != null ) {
@@ -145,6 +166,7 @@ public static final class Deserializer implements JsonDeserializer<SentryLogEven
145166 final @ NotNull ObjectReader reader , final @ NotNull ILogger logger ) throws Exception {
146167 @ Nullable Map <String , Object > unknown = null ;
147168 @ Nullable SentryId traceId = null ;
169+ @ Nullable SpanId spanId = null ;
148170 @ Nullable Double timestamp = null ;
149171 @ Nullable String body = null ;
150172 @ Nullable SentryLogLevel level = null ;
@@ -158,6 +180,9 @@ public static final class Deserializer implements JsonDeserializer<SentryLogEven
158180 case JsonKeys .TRACE_ID :
159181 traceId = reader .nextOrNull (logger , new SentryId .Deserializer ());
160182 break ;
183+ case JsonKeys .SPAN_ID :
184+ spanId = reader .nextOrNull (logger , new SpanId .Deserializer ());
185+ break ;
161186 case JsonKeys .TIMESTAMP :
162187 timestamp = reader .nextDoubleOrNull ();
163188 break ;
@@ -216,6 +241,7 @@ public static final class Deserializer implements JsonDeserializer<SentryLogEven
216241
217242 logEvent .setAttributes (attributes );
218243 logEvent .setSeverityNumber (severityNumber );
244+ logEvent .setSpanId (spanId );
219245 logEvent .setUnknown (unknown );
220246
221247 return logEvent ;
0 commit comments