File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
main/java/datadog/trace/core
test/groovy/datadog/trace/core Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 55import static datadog .trace .api .cache .RadixTreeCache .HTTP_STATUSES ;
66import static datadog .trace .bootstrap .instrumentation .api .ErrorPriorities .UNSET ;
77
8+ import datadog .trace .api .DDSpanId ;
89import datadog .trace .api .DDTags ;
910import datadog .trace .api .DDTraceId ;
1011import datadog .trace .api .Functions ;
@@ -892,9 +893,9 @@ public String toString() {
892893 .append ("DDSpan [ t_id=" )
893894 .append (traceId )
894895 .append (", s_id=" )
895- .append (spanId )
896+ .append (DDSpanId . toString ( spanId ) )
896897 .append (", p_id=" )
897- .append (parentId )
898+ .append (DDSpanId . toString ( parentId ) )
898899 .append (" ] trace=" )
899900 .append (getServiceName ())
900901 .append ('/' )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import static datadog.trace.core.DDSpanContext.SPAN_SAMPLING_MAX_PER_SECOND_TAG
1919class DDSpanContextTest extends DDCoreSpecification {
2020
2121 def writer
22- def tracer
22+ CoreTracer tracer
2323 def profilingContextIntegration
2424
2525 def setup () {
@@ -289,6 +289,29 @@ class DDSpanContextTest extends DDCoreSpecification {
289289 " _dd.${ tag} .json"
290290 }
291291
292+ def " Span IDs printed as unsigned long" () {
293+ setup :
294+ def parent = tracer. buildSpan(" fakeOperation" )
295+ .withServiceName(" fakeService" )
296+ .withResourceName(" fakeResource" )
297+ .withSpanId(-987654321 )
298+ .start()
299+
300+ def span = tracer. buildSpan(" fakeOperation" )
301+ .withServiceName(" fakeService" )
302+ .withResourceName(" fakeResource" )
303+ .withSpanId(-123456789 )
304+ .asChildOf(parent. context())
305+ .start()
306+
307+ def context = span. context() as DDSpanContext
308+
309+ expect :
310+ // even though span ID and parent ID are setup as negative numbers, they should be printed as their unsigned value
311+ // asserting there is no negative sign after ids is the best I can do.
312+ context. toString(). contains(" id=-" ) == false
313+ }
314+
292315 static void assertTagmap (Map source , Map comparison , boolean removeThread = false ) {
293316 def sourceWithoutCommonTags = new HashMap (source)
294317 sourceWithoutCommonTags. remove(" runtime-id" )
You can’t perform that action at this time.
0 commit comments