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:47 UTC
[openwhisk] 04/08: Use transaction to calculate
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 09451419f67d9d4a4d7d66a18bc680c5d7cca980
Author: ning.yougang <ni...@navercorp.com>
AuthorDate: Tue May 10 13:23:59 2022 +0800
Use transaction to calculate
---
.../apache/openwhisk/core/containerpool/docker/DockerClient.scala | 5 ++---
.../openwhisk/core/containerpool/kubernetes/KubernetesClient.scala | 4 +---
2 files changed, 3 insertions(+), 6 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 296c5eb58..d4196c0a8 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
@@ -39,6 +39,7 @@ import org.apache.openwhisk.core.ConfigKeys
import org.apache.openwhisk.core.containerpool.ContainerId
import org.apache.openwhisk.core.containerpool.ContainerAddress
+import java.time.Instant
import scala.concurrent.duration.Duration
object DockerContainerId {
@@ -203,14 +204,12 @@ 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(_) =>
- val t1 = System.currentTimeMillis()
MetricEmitter.emitHistogramMetric(
LogMarkerToken("docker", "runCmd", "duration", Some(args.head), Map("cmd" -> args.head))(
MeasurementUnit.time.milliseconds),
- t1 - t0)
+ Instant.now.toEpochMilli - transid.meta.start.toEpochMilli)
transid.finished(this, start)
case Failure(pte: ProcessTimeoutException) =>
transid.failed(this, start, pte.getMessage, ErrorLevel)
diff --git a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
index 5ba09f11d..5c4e6765f 100644
--- a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
+++ b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
@@ -151,7 +151,6 @@ class KubernetesClient(
log.info(this, s"Pod spec being created\n${Serialization.asYaml(pod)}")
}
val namespace = kubeRestClient.getNamespace
- val t0 = System.currentTimeMillis()
val start = transid.started(
this,
LoggingMarkers.INVOKER_KUBEAPI_CMD("create"),
@@ -183,11 +182,10 @@ class KubernetesClient(
waitForPod(namespace, createdPod, start.start, config.timeouts.run)
.map { readyPod =>
transid.finished(this, start, logLevel = InfoLevel)
- val t1 = System.currentTimeMillis()
MetricEmitter.emitHistogramMetric(
LogMarkerToken("kubeapi", "create", "duration", Some("create"), Map("cmd" -> "create"))(
MeasurementUnit.time.milliseconds),
- t1 - t0)
+ Instant.now.toEpochMilli - transid.meta.start.toEpochMilli)
toContainer(readyPod)
}
.recoverWith {