File tree Expand file tree Collapse file tree
main/java/datadog/trace/common/writer
test/java/datadog/trace/common/writer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -243,14 +243,16 @@ private String serializeTestEvent(CoreSpan<?> span) {
243243 w .name ("content" );
244244 w .beginObject ();
245245
246+ // trace/span/parent ids are unsigned 64-bit integers; emit as raw JSON numbers
247+ // (value(long) would reinterpret ids >= 2^63 as negative signed longs).
246248 if (traceId != null ) {
247- w .name ("trace_id" ).value (Long .toUnsignedString (traceId ));
249+ w .name ("trace_id" ).jsonValue (Long .toUnsignedString (traceId ));
248250 }
249251 if (spanId != null ) {
250- w .name ("span_id" ).value (Long .toUnsignedString (spanId ));
252+ w .name ("span_id" ).jsonValue (Long .toUnsignedString (spanId ));
251253 }
252254 if (parentId != null ) {
253- w .name ("parent_id" ).value (Long .toUnsignedString (parentId ));
255+ w .name ("parent_id" ).jsonValue (Long .toUnsignedString (parentId ));
254256 }
255257 if (testSessionId != null ) {
256258 w .name (Tags .TEST_SESSION_ID ).value (testSessionId .toLong ());
Original file line number Diff line number Diff line change @@ -102,6 +102,10 @@ void citestcycleFlushWritesEnvelopeWithVersionMetadataAndEvents(@TempDir Path ou
102102 assertEquals (456L , content .get (Tags .TEST_MODULE_ID ).asLong ());
103103 assertEquals (789L , content .get (Tags .TEST_SUITE_ID ).asLong ());
104104 assertEquals ("corr-1" , content .get (Tags .ITR_CORRELATION_ID ).asText ());
105+ // trace/span/parent ids must be JSON numbers (backend schema rejects strings)
106+ assertTrue (content .get ("trace_id" ).isNumber (), "trace_id should be a JSON number" );
107+ assertTrue (content .get ("span_id" ).isNumber (), "span_id should be a JSON number" );
108+ assertTrue (content .get ("parent_id" ).isNumber (), "parent_id should be a JSON number" );
105109 }
106110
107111 @ Test
You can’t perform that action at this time.
0 commit comments