You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ni...@apache.org on 2022/05/26 08:00:46 UTC

[openwhisk] 03/08: Add docker container creation consume time metric

This is an automated email from the ASF dual-hosted git repository.

ningyougang pushed a commit to branch add-container-count-metric
in repository https://gitbox.apache.org/repos/asf/openwhisk.git

commit df68fc2a51e397dc8bdaed4fc7cc4d45071dfe09
Author: ning.yougang <ni...@navercorp.com>
AuthorDate: Sun Apr 24 15:47:23 2022 +0800

    Add docker container creation consume time metric
---
 .../openwhisk/core/containerpool/docker/DockerClient.scala  | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerClient.scala b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerClient.scala
index b594f74ef..296c5eb58 100644
--- a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerClient.scala
+++ b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerClient.scala
@@ -21,7 +21,6 @@ import java.io.FileNotFoundException
 import java.nio.file.Files
 import java.nio.file.Paths
 import java.util.concurrent.Semaphore
-
 import akka.actor.ActorSystem
 
 import scala.collection.concurrent.TrieMap
@@ -32,9 +31,10 @@ import scala.util.Failure
 import scala.util.Success
 import scala.util.Try
 import akka.event.Logging.{ErrorLevel, InfoLevel}
+import kamon.metric.MeasurementUnit
 import pureconfig._
 import pureconfig.generic.auto._
-import org.apache.openwhisk.common.{Logging, LoggingMarkers, MetricEmitter, TransactionId}
+import org.apache.openwhisk.common.{LogMarkerToken, Logging, LoggingMarkers, MetricEmitter, TransactionId}
 import org.apache.openwhisk.core.ConfigKeys
 import org.apache.openwhisk.core.containerpool.ContainerId
 import org.apache.openwhisk.core.containerpool.ContainerAddress
@@ -203,8 +203,15 @@ class DockerClient(dockerHost: Option[String] = None,
       LoggingMarkers.INVOKER_DOCKER_CMD(args.head),
       s"running ${cmd.mkString(" ")} (timeout: $timeout)",
       logLevel = InfoLevel)
+    val t0 = System.currentTimeMillis()
     executeProcess(cmd, timeout).andThen {
-      case Success(_) => transid.finished(this, start)
+      case Success(_) =>
+        val t1 = System.currentTimeMillis()
+        MetricEmitter.emitHistogramMetric(
+          LogMarkerToken("docker", "runCmd", "duration", Some(args.head), Map("cmd" -> args.head))(
+            MeasurementUnit.time.milliseconds),
+          t1 - t0)
+        transid.finished(this, start)
       case Failure(pte: ProcessTimeoutException) =>
         transid.failed(this, start, pte.getMessage, ErrorLevel)
         MetricEmitter.emitCounterMetric(LoggingMarkers.INVOKER_DOCKER_CMD_TIMEOUT(args.head))