markusthoemmes commented on a change in pull request #3343: Support time-series 
DB using Kamon Tag, and optional granular metric.
URL: 
https://github.com/apache/incubator-openwhisk/pull/3343#discussion_r170511407
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/common/Logging.scala
 ##########
 @@ -164,27 +164,47 @@ private object Logging {
     if (simpleName.endsWith("$")) simpleName.dropRight(1)
     else simpleName
   }
-
 }
 
 private object Emitter {
   val timeFormat = 
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneId.of("UTC"))
 }
 
-case class LogMarkerToken(component: String, action: String, state: String) {
+/**
+ * Used to record log message and make a metric name.
+ *
+ * @param component Component like invoker, controller, and docker. It is 
defined in LoggingMarkers.
+ * @param action Action of the component.
+ * @param state State of the action.
+ * @param macroTags macroTags should be used for tags with a bounded number of 
permutations.
+ * @param microTags microTags can be used for whatever granularity you might 
need.
+ */
+case class LogMarkerToken(component: String,
+                          action: String,
+                          state: String,
+                          macroTags: Map[String, String] = Map.empty,
+                          microTags: Map[String, String] = Map.empty) {
+
   override def toString() = component + "_" + action + "_" + state
 
+  // folderLeft is used instead of mkString(".", ".", ""),
+  // because Map.empty.mkString returns "."
+  def toStringWithTags = component + "_" + action + 
getTags.values.foldLeft("")((a, v) => a + "." + v) + "_" + state
 
 Review comment:
   You can simplify to
   
   ```scala
   def toStringWithTags(includeMicroTags: Boolean) = {
     val tags = if(includeMicroTags) macroTags ++ microTags else macroTags
     val tagString = tags.values.foldLeft("")(_ + "." + _) // graceful handling 
of an empty map
     component + "_" + action + tagString + "_" + state
   }
   ```
   
   **Note:** I'd remove the entanglement of this instance to some arbitrary 
global value and pass it in instead for better control (in tests for instance).

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to