@@ -2,6 +2,9 @@ package at.ac.uibk.dps.cirrina.execution.`object`
22
33import at.ac.uibk.dps.cirrina.csm.Csml.EventChannel
44import at.ac.uibk.dps.cirrina.execution.service.ServiceImplementationSelector
5+ import io.micrometer.core.instrument.MeterRegistry
6+ import io.micrometer.core.instrument.Tag
7+ import io.micrometer.core.instrument.Tags
58import kotlinx.coroutines.CoroutineScope
69import kotlinx.coroutines.launch
710import mu.KotlinLogging
@@ -16,6 +19,7 @@ class ActionExecutor(
1619 private val selector : ServiceImplementationSelector ,
1720 private val eventHandler : StateMachine .StateMachineEventHandler ,
1821 private val coroutineScope : CoroutineScope ,
22+ private val meterRegistry : MeterRegistry ,
1923) {
2024 fun execute (action : Action , scope : Scope ): List <Action > =
2125 when (action) {
@@ -26,6 +30,7 @@ class ActionExecutor(
2630 is TimeoutAction -> listOf (action.triggers)
2731 is TimeoutResetAction -> emptyList()
2832 is LogAction -> executeLog(action, scope)
33+ is IncrCtrAction -> executeIncrCtr(action, scope)
2934 else -> error(" unknown action type: ${action::class .simpleName} " )
3035 }
3136
@@ -84,4 +89,13 @@ class ActionExecutor(
8489 action.message.execute(scope.extent).toString().also { logger.info(it) }
8590 return emptyList()
8691 }
92+
93+ private fun executeIncrCtr (action : IncrCtrAction , scope : Scope ): List <Action > {
94+ val tags =
95+ Tags .of(
96+ action.tag.map { (key, value) -> Tag .of(key, value.execute(scope.extent).toString()) }
97+ )
98+ meterRegistry.counter(action.counter, tags).increment(action.by.toDouble())
99+ return emptyList()
100+ }
87101}
0 commit comments