Skip to content

Commit 41e38e7

Browse files
committed
Only write W3CTracestate when available
1 parent e2c3423 commit 41e38e7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

dd-trace-core/src/main/java/datadog/trace/core/otlp/trace/OtlpTraceProto.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ public static byte[] recordSpanMessage(
8989
writeTag(buf, 2, LEN_WIRE_TYPE);
9090
writeSpanId(buf, span.getSpanId());
9191

92-
writeTag(buf, 3, LEN_WIRE_TYPE);
93-
writeString(buf, propagationTags.getW3CTracestate());
92+
String tracestate = propagationTags.getW3CTracestate();
93+
if (tracestate != null) {
94+
writeTag(buf, 3, LEN_WIRE_TYPE);
95+
writeString(buf, tracestate);
96+
}
9497

9598
if (span.getParentId() != 0) {
9699
writeTag(buf, 4, LEN_WIRE_TYPE);
@@ -238,7 +241,9 @@ private static void writeSpanTag(StreamingBuffer buf, UTF8BytesString key, long
238241
}
239242

240243
private static int spanKind(CharSequence spanKind) {
241-
if (SPAN_KIND_SERVER.contentEquals(spanKind)) {
244+
if (spanKind == null) {
245+
return 1; // UNSPECIFIED -> INTERNAL
246+
} else if (SPAN_KIND_SERVER.contentEquals(spanKind)) {
242247
return 2; // SERVER
243248
} else if (SPAN_KIND_CLIENT.contentEquals(spanKind)) {
244249
return 3; // CLIENT

0 commit comments

Comments
 (0)