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 2018/02/21 19:41:20 UTC

[GitHub] markusthoemmes closed pull request #3316: Add conditional statement to check metricsKamon flag.

markusthoemmes closed pull request #3316: Add conditional statement to check metricsKamon flag.
URL: https://github.com/apache/incubator-openwhisk/pull/3316
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/scala/src/main/scala/whisk/common/Logging.scala b/common/scala/src/main/scala/whisk/common/Logging.scala
index 4f4a80115b..cce6b913f6 100644
--- a/common/scala/src/main/scala/whisk/common/Logging.scala
+++ b/common/scala/src/main/scala/whisk/common/Logging.scala
@@ -192,15 +192,19 @@ object MetricEmitter {
   val metrics = Kamon.metrics
 
   def emitCounterMetric(token: LogMarkerToken): Unit = {
-    metrics
-      .counter(token.toString)
-      .increment(1)
+    if (TransactionId.metricsKamon) {
+      metrics
+        .counter(token.toString)
+        .increment(1)
+    }
   }
 
   def emitHistogramMetric(token: LogMarkerToken, value: Long): Unit = {
-    metrics
-      .histogram(token.toString)
-      .record(value)
+    if (TransactionId.metricsKamon) {
+      metrics
+        .histogram(token.toString)
+        .record(value)
+    }
   }
 
 }
diff --git a/common/scala/src/main/scala/whisk/common/TransactionId.scala b/common/scala/src/main/scala/whisk/common/TransactionId.scala
index 09ca1fd894..704c03dddc 100644
--- a/common/scala/src/main/scala/whisk/common/TransactionId.scala
+++ b/common/scala/src/main/scala/whisk/common/TransactionId.scala
@@ -63,9 +63,7 @@ case class TransactionId private (meta: TransactionMetadata) extends AnyVal {
       logging.emit(logLevel, this, from, message)
     }
 
-    if (TransactionId.metricsKamon) {
-      MetricEmitter.emitCounterMetric(marker)
-    }
+    MetricEmitter.emitCounterMetric(marker)
 
   }
 
@@ -90,10 +88,7 @@ case class TransactionId private (meta: TransactionMetadata) extends AnyVal {
       logging.emit(logLevel, this, from, message)
     }
 
-    if (TransactionId.metricsKamon) {
-      MetricEmitter.emitCounterMetric(marker)
-    }
-
+    MetricEmitter.emitCounterMetric(marker)
     StartMarker(Instant.now, marker)
   }
 
@@ -126,9 +121,7 @@ case class TransactionId private (meta: TransactionMetadata) extends AnyVal {
       logging.emit(logLevel, this, from, message)
     }
 
-    if (TransactionId.metricsKamon) {
-      MetricEmitter.emitHistogramMetric(endMarker, deltaToEnd)
-    }
+    MetricEmitter.emitHistogramMetric(endMarker, deltaToEnd)
   }
 
   /**
@@ -156,10 +149,8 @@ case class TransactionId private (meta: TransactionMetadata) extends AnyVal {
       logging.emit(logLevel, this, from, message)
     }
 
-    if (TransactionId.metricsKamon) {
-      MetricEmitter.emitHistogramMetric(endMarker, deltaToEnd)
-      MetricEmitter.emitCounterMetric(endMarker)
-    }
+    MetricEmitter.emitHistogramMetric(endMarker, deltaToEnd)
+    MetricEmitter.emitCounterMetric(endMarker)
   }
 
   /**
diff --git a/common/scala/src/main/scala/whisk/http/BasicHttpService.scala b/common/scala/src/main/scala/whisk/http/BasicHttpService.scala
index 914c199133..46b95e04a6 100644
--- a/common/scala/src/main/scala/whisk/http/BasicHttpService.scala
+++ b/common/scala/src/main/scala/whisk/http/BasicHttpService.scala
@@ -124,10 +124,9 @@ trait BasicHttpService extends Directives with TransactionCounter {
       val token = LogMarkerToken("http", s"${m.toLowerCase}.${res.status.intValue}", LoggingMarkers.count)
       val marker = LogMarker(token, tid.deltaToStart, Some(tid.deltaToStart))
 
-      if (TransactionId.metricsKamon) {
-        MetricEmitter.emitHistogramMetric(token, tid.deltaToStart)
-        MetricEmitter.emitCounterMetric(token)
-      }
+      MetricEmitter.emitHistogramMetric(token, tid.deltaToStart)
+      MetricEmitter.emitCounterMetric(token)
+
       if (TransactionId.metricsLog) {
         Some(LogEntry(s"[$tid] [$name] $marker", l))
       } else {


 

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