Skip to content

Commit 513fccd

Browse files
committed
Use transaction to calculate
1 parent 1ecbaf6 commit 513fccd

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/docker/DockerClient.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.apache.openwhisk.core.ConfigKeys
3939
import org.apache.openwhisk.core.containerpool.ContainerId
4040
import org.apache.openwhisk.core.containerpool.ContainerAddress
4141

42+
import java.time.Instant
4243
import scala.concurrent.duration.Duration
4344

4445
object DockerContainerId {
@@ -203,14 +204,12 @@ class DockerClient(dockerHost: Option[String] = None,
203204
LoggingMarkers.INVOKER_DOCKER_CMD(args.head),
204205
s"running ${cmd.mkString(" ")} (timeout: $timeout)",
205206
logLevel = InfoLevel)
206-
val t0 = System.currentTimeMillis()
207207
executeProcess(cmd, timeout).andThen {
208208
case Success(_) =>
209-
val t1 = System.currentTimeMillis()
210209
MetricEmitter.emitHistogramMetric(
211210
LogMarkerToken("docker", "runCmd", "duration", Some(args.head), Map("cmd" -> args.head))(
212211
MeasurementUnit.time.milliseconds),
213-
t1 - t0)
212+
Instant.now.toEpochMilli - transid.meta.start.toEpochMilli)
214213
transid.finished(this, start)
215214
case Failure(pte: ProcessTimeoutException) =>
216215
transid.failed(this, start, pte.getMessage, ErrorLevel)

core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ class KubernetesClient(
151151
log.info(this, s"Pod spec being created\n${Serialization.asYaml(pod)}")
152152
}
153153
val namespace = kubeRestClient.getNamespace
154-
val t0 = System.currentTimeMillis()
155154
val start = transid.started(
156155
this,
157156
LoggingMarkers.INVOKER_KUBEAPI_CMD("create"),
@@ -183,11 +182,10 @@ class KubernetesClient(
183182
waitForPod(namespace, createdPod, start.start, config.timeouts.run)
184183
.map { readyPod =>
185184
transid.finished(this, start, logLevel = InfoLevel)
186-
val t1 = System.currentTimeMillis()
187185
MetricEmitter.emitHistogramMetric(
188186
LogMarkerToken("kubeapi", "create", "duration", Some("create"), Map("cmd" -> "create"))(
189187
MeasurementUnit.time.milliseconds),
190-
t1 - t0)
188+
Instant.now.toEpochMilli - transid.meta.start.toEpochMilli)
191189
toContainer(readyPod)
192190
}
193191
.recoverWith {

0 commit comments

Comments
 (0)