Skip to content

Commit 8d93099

Browse files
committed
replace string concatenation by string builder
1 parent 4a4b35f commit 8d93099

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

dd-trace-core/src/main/java/datadog/trace/core/propagation/W3CTraceParent.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
public final class W3CTraceParent {
1414

15+
private static final int TRACE_PARENT_LENGTH = 55;
16+
1517
private W3CTraceParent() {}
1618

1719
/**
@@ -25,11 +27,14 @@ private W3CTraceParent() {}
2527
* @return the W3C traceparent header value
2628
*/
2729
public static String from(DDTraceId traceId, long spanId, int samplingPriority) {
28-
return "00-"
29-
+ traceId.toHexString()
30-
+ '-'
31-
+ DDSpanId.toHexStringPadded(spanId)
32-
+ (samplingPriority > 0 ? "-01" : "-00");
30+
StringBuilder sb = new StringBuilder(TRACE_PARENT_LENGTH);
31+
sb.append("00-");
32+
sb.append(traceId.toHexString());
33+
sb.append('-');
34+
sb.append(DDSpanId.toHexStringPadded(spanId));
35+
sb.append(samplingPriority > 0 ? "-01" : "-00");
36+
37+
return sb.toString();
3338
}
3439

3540
public static String from(AgentSpan span) {

0 commit comments

Comments
 (0)