Skip to content

Commit 35ee37f

Browse files
committed
reformat trace parent util
1 parent fa7d331 commit 35ee37f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

dd-java-agent/instrumentation/mongo/common/src/main/java/datadog/trace/instrumentation/mongo/MongoCommentInjector.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.DBM_TRACE_INJECTED;
55

66
import datadog.trace.api.Config;
7+
import datadog.trace.api.DDSpanId;
78
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
89
import datadog.trace.bootstrap.instrumentation.dbm.SharedDBCommenter;
910
import org.bson.BsonArray;
@@ -114,13 +115,10 @@ private static BsonValue mergeComment(BsonValue existingComment, String dbmComme
114115

115116
static String buildTraceParent(AgentSpan span) {
116117
// W3C traceparent format: version-traceId-spanId-flags
117-
return "00-"
118-
+ // version
119-
span.getTraceId().toHexStringPadded(32)
120-
+ // traceId
121-
'-'
122-
+ String.format("%016x", span.getSpanId())
123-
+ // spanId
124-
(span.context().getSamplingPriority() > 0 ? "-01" : "-00");
118+
return "00-" // version
119+
+ span.getTraceId().toHexString() // traceId
120+
+ '-'
121+
+ DDSpanId.toHexStringPadded(span.getSpanId()) // spanId
122+
+ (span.context().getSamplingPriority() > 0 ? "-01" : "-00");
125123
}
126124
}

0 commit comments

Comments
 (0)