|
52 | 52 | /** Provides optimized writers for OpenTelemetry's "trace.proto" wire protocol. */ |
53 | 53 | public final class OtlpTraceProto { |
54 | 54 |
|
| 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 | + |
55 | 60 | static final int NO_TRACE_FLAGS = 0x00000000; |
56 | 61 | static final int SAMPLED_TRACE_FLAG = 0x00000001; |
57 | 62 | static final int REMOTE_TRACE_FLAG = 0x00000300; |
@@ -130,15 +135,11 @@ public static byte[] recordSpanMessage( |
130 | 135 | writeI64(buf, span.getStartTime() + PendingTrace.getDurationNano(span)); |
131 | 136 |
|
132 | 137 | 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()); |
135 | 139 | } |
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()); |
142 | 143 |
|
143 | 144 | span.processTagsAndBaggage(metaWriter); |
144 | 145 |
|
|
0 commit comments