Skip to content

Commit 00dd503

Browse files
committed
Re-use writeSpanTag
1 parent 4adb56e commit 00dd503

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
/** Provides optimized writers for OpenTelemetry's "trace.proto" wire protocol. */
5353
public final class OtlpTraceProto {
5454

55+
private static final UTF8BytesString SERVICE_NAME = UTF8BytesString.create("service.name");
56+
private static final UTF8BytesString RESOURCE_NAME = UTF8BytesString.create("resource.name");
57+
private static final UTF8BytesString OPERATION_NAME = UTF8BytesString.create("operation.name");
58+
private static final UTF8BytesString SPAN_TYPE = UTF8BytesString.create("span.type");
59+
5560
static final int NO_TRACE_FLAGS = 0x00000000;
5661
static final int SAMPLED_TRACE_FLAG = 0x00000001;
5762
static final int REMOTE_TRACE_FLAG = 0x00000300;
@@ -130,15 +135,11 @@ public static byte[] recordSpanMessage(
130135
writeI64(buf, span.getStartTime() + PendingTrace.getDurationNano(span));
131136

132137
if (!Config.get().getServiceName().equalsIgnoreCase(span.getServiceName())) {
133-
writeTag(buf, 9, LEN_WIRE_TYPE);
134-
writeAttribute(buf, STRING, "service.name", span.getServiceName());
138+
writeSpanTag(buf, SERVICE_NAME, span.getServiceName());
135139
}
136-
writeTag(buf, 9, LEN_WIRE_TYPE);
137-
writeAttribute(buf, STRING, "resource.name", span.getResourceName());
138-
writeTag(buf, 9, LEN_WIRE_TYPE);
139-
writeAttribute(buf, STRING, "operation.name", span.getOperationName());
140-
writeTag(buf, 9, LEN_WIRE_TYPE);
141-
writeAttribute(buf, STRING, "span.type", span.getSpanType());
140+
writeSpanTag(buf, RESOURCE_NAME, span.getResourceName());
141+
writeSpanTag(buf, OPERATION_NAME, span.getOperationName());
142+
writeSpanTag(buf, SPAN_TYPE, span.getSpanType());
142143

143144
span.processTagsAndBaggage(metaWriter);
144145

0 commit comments

Comments
 (0)