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 db90668bd46485c468a5f74763dbc7f575c06ca4 Author: ning.yougang <[email protected]> AuthorDate: Sun Apr 24 15:40:51 2022 +0800 Add pod creation consume time metric --- .../containerpool/kubernetes/KubernetesClient.scala | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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 9dd588eda..5ba09f11d 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 @@ -22,7 +22,6 @@ import java.net.SocketTimeoutException import java.time.format.DateTimeFormatterBuilder import java.time.temporal.ChronoField import java.time.{Instant, ZoneId} - import akka.actor.ActorSystem import akka.event.Logging.ErrorLevel import akka.event.Logging.InfoLevel @@ -38,11 +37,18 @@ import collection.JavaConverters._ import io.fabric8.kubernetes.api.model._ import io.fabric8.kubernetes.client.utils.Serialization import io.fabric8.kubernetes.client.{ConfigBuilder, DefaultKubernetesClient} +import kamon.metric.MeasurementUnit import okhttp3.{Call, Callback, Request, Response} import okio.BufferedSource import org.apache.commons.lang3.exception.ExceptionUtils -import org.apache.openwhisk.common.LoggingMarkers -import org.apache.openwhisk.common.{ConfigMapValue, Logging, TransactionId} +import org.apache.openwhisk.common.{ + ConfigMapValue, + LogMarkerToken, + Logging, + LoggingMarkers, + MetricEmitter, + TransactionId +} import org.apache.openwhisk.core.ConfigKeys import org.apache.openwhisk.core.containerpool.docker.ProcessRunner import org.apache.openwhisk.core.containerpool.{ContainerAddress, ContainerId} @@ -145,6 +151,7 @@ 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"), @@ -176,6 +183,11 @@ 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) toContainer(readyPod) } .recoverWith {
