GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix printing format of span identifiers (#8897) · DataDog/dd-trace-java@3070e2e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • dd-trace-core/src
    • main/java/datadog/trace/core
      • DDSpanContext.java
    • test/groovy/datadog/trace/core
      • DDSpanContextTest.groovy
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java‎

Copy file name to clipboardExpand all lines: dd-trace-core/src/main/java/datadog/trace/core/DDSpanContext.java
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static datadog.trace.api.cache.RadixTreeCache.HTTP_STATUSES;
66
import static datadog.trace.bootstrap.instrumentation.api.ErrorPriorities.UNSET;
77

8+
import datadog.trace.api.DDSpanId;
89
import datadog.trace.api.DDTags;
910
import datadog.trace.api.DDTraceId;
1011
import 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('/')
Collapse file

‎dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy‎

Copy file name to clipboardExpand all lines: dd-trace-core/src/test/groovy/datadog/trace/core/DDSpanContextTest.groovy
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import static datadog.trace.core.DDSpanContext.SPAN_SAMPLING_MAX_PER_SECOND_TAG
1919
class 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")

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.