static void write(String key, String stringValue, byte[] endpointBytes, WriteBuffer buffer) {
      KEY.write(buffer);
      ThriftCodec.writeLengthPrefixed(buffer, key);

      VALUE.write(buffer);
      int type = 0;
      if (stringValue != null) {
        type = 6;
        ThriftCodec.writeInt(buffer, utf8SizeInBytes(stringValue));
        buffer.writeUtf8(stringValue);
      } else {
        ThriftCodec.writeInt(buffer, 1);
        buffer.writeByte(1);
      }

      TYPE.write(buffer);
      ThriftCodec.writeInt(buffer, type);

      if (endpointBytes != null) {
        ENDPOINT.write(buffer);
        buffer.write(endpointBytes);
      }

      buffer.writeByte(TYPE_STOP);
    }
This type isn't thread-safe: it re-uses state to avoid re-allocations in conversion loops.
zipkin/src/main/java/zipkin2/internal/V1ThriftSpanWriter.java