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/01/10 10:51:27 UTC

[GitHub] markusthoemmes commented on a change in pull request #4212: Optimize Kamon metric update flow

markusthoemmes commented on a change in pull request #4212: Optimize Kamon metric update flow
URL: https://github.com/apache/incubator-openwhisk/pull/4212#discussion_r246713068
 
 

 ##########
 File path: common/scala/src/main/scala/org/apache/openwhisk/common/Logging.scala
 ##########
 @@ -184,13 +185,71 @@ case class LogMarkerToken(component: String,
                           state: String,
                           subAction: Option[String] = None,
                           tags: Map[String, String] = Map.empty) {
+  private var finishToken: LogMarkerToken = _
+  private var errorToken: LogMarkerToken = _
+  private var _counter: KCounter = _
+  private var _histogram: KHistogram = _
 
   override val toString = component + "_" + action + "_" + state
-  val toStringWithSubAction =
+  val toStringWithSubAction: String =
     subAction.map(sa => component + "_" + action + "." + sa + "_" + state).getOrElse(toString)
 
-  def asFinish = copy(state = LoggingMarkers.finish)
-  def asError = copy(state = LoggingMarkers.error)
+  def asFinish: LogMarkerToken = {
+    if (finishToken == null) {
+      finishToken = copy(state = LoggingMarkers.finish)
+    }
+    finishToken
+  }
+
+  def asError: LogMarkerToken = {
+    if (errorToken == null) {
+      errorToken = copy(state = LoggingMarkers.error)
+    }
+    errorToken
+  }
 
 Review comment:
   Is it worth caching `asFinish` or `asError` this way? Are these used multiple times in reality often?

----------------------------------------------------------------
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