You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/03/15 04:35:00 UTC

[GitHub] [incubator-openwhisk] chetanmeh commented on a change in pull request #4348: Fixes the issue of failing to read empty Splunk JSON objects

chetanmeh commented on a change in pull request #4348: Fixes the issue of failing to read empty Splunk JSON objects
URL: https://github.com/apache/incubator-openwhisk/pull/4348#discussion_r265847634
 
 

 ##########
 File path: common/scala/src/main/scala/org/apache/openwhisk/core/containerpool/logging/SplunkLogStore.scala
 ##########
 @@ -137,10 +137,17 @@ class SplunkLogStore(
             ActivationLogs(
               r.results
                 .map(l =>
-                  //format same as org.apache.openwhisk.core.containerpool.logging.LogLine.toFormattedString
-                  f"${l.fields(splunkConfig.logTimestampField).convertTo[String]}%-30s ${l
-                    .fields(splunkConfig.logStreamField)
-                    .convertTo[String]}: ${l.fields(splunkConfig.logMessageField).convertTo[String].trim}"))
+                  try {
 
 Review comment:
   Instead of using simple try...catch you can use [Scala Try][1]. This ensures that you do not eat up fatal exception and also handle the failure case in bit more functional way!
   
   ```suggestion
    r.results
                     .map(js => Try(toLogLine(js)))
                     .map {
                       case Success(s) => s
                       case Failure(t) =>
                         logging.debug(
                           this,
                           s"The log message might have been too large " +
                             s"for '${splunkConfig.index}' Splunk index and can't be retrieved, ${t.getMessage}")
                         s"The log message can't be retrieved, ${t.getMessage}"
                     })
   ```
   
   [1]: https://danielwestheide.com/blog/2012/12/26/the-neophytes-guide-to-scala-part-6-error-handling-with-try.html

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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