You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/02/15 01:23:39 UTC

[GitHub] kristw commented on a change in pull request #6879: Improve Superset logger

kristw commented on a change in pull request #6879: Improve Superset logger
URL: https://github.com/apache/incubator-superset/pull/6879#discussion_r257070164
 
 

 ##########
 File path: superset/assets/src/middleware/loggerMiddleware.js
 ##########
 @@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 
 Review comment:
   If the `messageQueue` is only used here by `loggerMiddleWare` and there is only one type of event (`append`) and one listener, I am wondering if we need to implement `on` and `dispatch` as if this will be called from multiple modules with multiple type of events?
   
   Would something like this be more concise?
   
   ```js
   const MAX_EVENTS_PER_REQUEST = 50; // I just pick randomly
   class LogMessageQueue {
     constructor() {
       this.queue = [];
       this.send = debounce(this.send.bind(this), 1000);
     }
     append(eventData) {
       this.queue.push(eventData);
       this.send();
     }
     send() {
       if (this.queue.length > 0) {
         const events = this.queue.splice(0, MAX_EVENTS_PER_REQUEST);
         // do the sendBeacon or POST call      
         // ...
         // `events` is the array of events to be sent (similar to your `eventDataList`)
   
         // If there are remaining items, call it again.
         if (this.queue.length > 0) {
           this.send();
         }
       }
     }
   }
   
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org