You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by bd...@apache.org on 2023/03/01 19:27:01 UTC

[openwhisk] branch master updated: remove action version from scheduler metrics without kamon (#5356)

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

bdoyle pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 96ff327dc remove action version from scheduler metrics without kamon (#5356)
96ff327dc is described below

commit 96ff327dcce25bdb91b59fd2746d1e3a2979143e
Author: Brendan Doyle <bd...@gmail.com>
AuthorDate: Wed Mar 1 11:26:54 2023 -0800

    remove action version from scheduler metrics without kamon (#5356)
    
    * remove action version from scheduler metrics without kamon
    
    * scalafmt
    
    ---------
    
    Co-authored-by: Brendan Doyle <br...@qualtrics.com>
---
 .../org/apache/openwhisk/common/Logging.scala      | 28 +++++++++++++---------
 .../core/entity/FullyQualifiedEntityName.scala     |  1 +
 .../core/scheduler/queue/MemoryQueue.scala         | 14 ++++++-----
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/common/scala/src/main/scala/org/apache/openwhisk/common/Logging.scala b/common/scala/src/main/scala/org/apache/openwhisk/common/Logging.scala
index ff82ef5fb..2bc3b1c81 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/common/Logging.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/common/Logging.scala
@@ -20,7 +20,6 @@ package org.apache.openwhisk.common
 import java.io.PrintStream
 import java.time.{Clock, Instant, ZoneId}
 import java.time.format.DateTimeFormatter
-
 import akka.event.Logging._
 import akka.event.LoggingAdapter
 import kamon.Kamon
@@ -372,20 +371,22 @@ object LoggingMarkers {
   def SCHEDULER_NAMESPACE_INPROGRESS_CONTAINER(namespace: String) =
     LogMarkerToken(scheduler, "namespaceInProgressContainer", counter, Some(namespace), Map("namespace" -> namespace))(
       MeasurementUnit.none)
-  def SCHEDULER_ACTION_CONTAINER(namespace: String, action: String) =
+  def SCHEDULER_ACTION_CONTAINER(namespace: String, actionWithVersion: String, actionWithoutVersion: String) =
     LogMarkerToken(
       scheduler,
       "actionContainer",
       counter,
-      Some(action),
-      Map("namespace" -> namespace, "action" -> action))(MeasurementUnit.none)
-  def SCHEDULER_ACTION_INPROGRESS_CONTAINER(namespace: String, action: String) =
+      Some(actionWithoutVersion),
+      Map("namespace" -> namespace, "action" -> actionWithVersion))(MeasurementUnit.none)
+  def SCHEDULER_ACTION_INPROGRESS_CONTAINER(namespace: String,
+                                            actionWithVersion: String,
+                                            actionWithoutVersion: String) =
     LogMarkerToken(
       scheduler,
       "actionInProgressContainer",
       counter,
-      Some(action),
-      Map("namespace" -> namespace, "action" -> action))(MeasurementUnit.none)
+      Some(actionWithoutVersion),
+      Map("namespace" -> namespace, "action" -> actionWithVersion))(MeasurementUnit.none)
 
   /*
    * Controller related markers
@@ -593,8 +594,8 @@ object LoggingMarkers {
   val SCHEDULER_KAFKA = LogMarkerToken(scheduler, kafka, start)(MeasurementUnit.time.milliseconds)
   val SCHEDULER_KAFKA_WAIT_TIME =
     LogMarkerToken(scheduler, "kafkaWaitTime", counter)(MeasurementUnit.time.milliseconds)
-  def SCHEDULER_WAIT_TIME(action: String) =
-    LogMarkerToken(scheduler, "waitTime", counter, Some(action), Map("action" -> action))(
+  def SCHEDULER_WAIT_TIME(actionWithVersion: String, actionWithoutVersion: String) =
+    LogMarkerToken(scheduler, "waitTime", counter, Some(actionWithoutVersion), Map("action" -> actionWithVersion))(
       MeasurementUnit.time.milliseconds)
 
   def SCHEDULER_KEEP_ALIVE(leaseId: Long) =
@@ -604,8 +605,13 @@ object LoggingMarkers {
   def SCHEDULER_QUEUE_RECOVER = LogMarkerToken(scheduler, "queueRecover", start)(MeasurementUnit.time.milliseconds)
   def SCHEDULER_QUEUE_UPDATE(reason: String) =
     LogMarkerToken(scheduler, "queueUpdate", counter, None, Map("reason" -> reason))(MeasurementUnit.none)
-  def SCHEDULER_QUEUE_WAITING_ACTIVATION(action: String) =
-    LogMarkerToken(scheduler, "queueActivation", counter, Some(action), Map("action" -> action))(MeasurementUnit.none)
+  def SCHEDULER_QUEUE_WAITING_ACTIVATION(namespace: String, actionWithVersion: String, actionWithoutVersion: String) =
+    LogMarkerToken(
+      scheduler,
+      "queueActivation",
+      counter,
+      Some(actionWithoutVersion),
+      Map("namespace" -> namespace, "action" -> actionWithVersion))(MeasurementUnit.none)
 
   /*
    * General markers
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/FullyQualifiedEntityName.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/FullyQualifiedEntityName.scala
index f76696766..4585fa262 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/core/entity/FullyQualifiedEntityName.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/entity/FullyQualifiedEntityName.scala
@@ -56,6 +56,7 @@ protected[core] case class FullyQualifiedEntityName(path: EntityPath,
   def namespace: EntityName = path.root
   def qualifiedNameWithLeadingSlash: String = EntityPath.PATHSEP + qualifiedName
   def asString = path.addPath(name) + version.map("@" + _.toString).getOrElse("")
+  def toStringWithoutVersion = path.addPath(name).asString
   def serialize = FullyQualifiedEntityName.serdes.write(this).compactPrint
 
   override def size = qualifiedName.sizeInBytes
diff --git a/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/MemoryQueue.scala b/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/MemoryQueue.scala
index 051e28976..8602702dd 100644
--- a/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/MemoryQueue.scala
+++ b/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/MemoryQueue.scala
@@ -181,7 +181,8 @@ class MemoryQueue(private val etcdClient: EtcdClient,
 
   private val logScheduler: Cancellable = context.system.scheduler.scheduleWithFixedDelay(0.seconds, 1.seconds) { () =>
     MetricEmitter.emitGaugeMetric(
-      LoggingMarkers.SCHEDULER_QUEUE_WAITING_ACTIVATION(s"$invocationNamespace/$action"),
+      LoggingMarkers
+        .SCHEDULER_QUEUE_WAITING_ACTIVATION(invocationNamespace, action.asString, action.toStringWithoutVersion),
       queue.size)
 
     MetricEmitter.emitGaugeMetric(
@@ -192,10 +193,11 @@ class MemoryQueue(private val etcdClient: EtcdClient,
       namespaceContainerCount.inProgressContainerNumByNamespace)
 
     MetricEmitter.emitGaugeMetric(
-      LoggingMarkers.SCHEDULER_ACTION_CONTAINER(invocationNamespace, action.asString),
+      LoggingMarkers.SCHEDULER_ACTION_CONTAINER(invocationNamespace, action.asString, action.toStringWithoutVersion),
       containers.size)
     MetricEmitter.emitGaugeMetric(
-      LoggingMarkers.SCHEDULER_ACTION_INPROGRESS_CONTAINER(invocationNamespace, action.asString),
+      LoggingMarkers
+        .SCHEDULER_ACTION_INPROGRESS_CONTAINER(invocationNamespace, action.asString, action.toStringWithoutVersion),
       creationIds.size)
   }
 
@@ -828,7 +830,7 @@ class MemoryQueue(private val etcdClient: EtcdClient,
 
     val totalTimeInScheduler = Interval(activation.transid.meta.start, Instant.now()).duration
     MetricEmitter.emitHistogramMetric(
-      LoggingMarkers.SCHEDULER_WAIT_TIME(action.asString),
+      LoggingMarkers.SCHEDULER_WAIT_TIME(action.asString, action.toStringWithoutVersion),
       totalTimeInScheduler.toMillis)
 
     val activationResponse =
@@ -1020,7 +1022,7 @@ class MemoryQueue(private val etcdClient: EtcdClient,
       .map { res =>
         val totalTimeInScheduler = Interval(msg.transid.meta.start, Instant.now()).duration
         MetricEmitter.emitHistogramMetric(
-          LoggingMarkers.SCHEDULER_WAIT_TIME(action.asString),
+          LoggingMarkers.SCHEDULER_WAIT_TIME(action.asString, action.toStringWithoutVersion),
           totalTimeInScheduler.toMillis)
         res.trySuccess(Right(msg))
         in.decrementAndGet()
@@ -1045,7 +1047,7 @@ class MemoryQueue(private val etcdClient: EtcdClient,
         msg.transid)
       val totalTimeInScheduler = Interval(msg.transid.meta.start, Instant.now()).duration
       MetricEmitter.emitHistogramMetric(
-        LoggingMarkers.SCHEDULER_WAIT_TIME(action.asString),
+        LoggingMarkers.SCHEDULER_WAIT_TIME(action.asString, action.toStringWithoutVersion),
         totalTimeInScheduler.toMillis)
 
       sender ! GetActivationResponse(Right(msg))