markusthoemmes commented on a change in pull request #2857: Emit metrics via kamon - wip URL: https://github.com/apache/incubator-openwhisk/pull/2857#discussion_r144827975
########## File path: common/scala/src/main/scala/whisk/common/Logging.scala ########## @@ -178,6 +179,34 @@ object LogMarkerToken { } } +trait WhiskMetric {} + +case class WhiskCounterMetric(component: String, action: String) extends WhiskMetric {} + +case class WhiskHistogramMetric(component: String, action: String, value: Long) extends WhiskMetric + +object MetricEmitter { + + def getMetricName(component: String, action: String, isFailed: Boolean = false): String = { + if (isFailed) { + component + "_" + action + "_failed" + } else { + component + "_" + action + } + } + + def emitMetric(wm: WhiskMetric, isFailed: Boolean = false) = wm match { + case WhiskCounterMetric(component, action) => + Kamon.metrics + .counter(getMetricName(component, action, isFailed)) + .increment(1) + case WhiskHistogramMetric(component, action, value) => + Kamon.metrics + .histogram(getMetricName(component, action, isFailed)) + .record(value) + } Review comment: Why not have an overloaded version of `emitMetric` and get rid of the intermediary types + non-needed allocations? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services