@@ -9,10 +9,14 @@ import com.cosmotech.api.events.ScenarioRunStartedForScenario
99import com.cosmotech.api.metrics.DownSamplingAggregationType
1010import com.cosmotech.api.metrics.PersistentMetric
1111import com.cosmotech.api.metrics.PersitentMetricType
12+ import com.cosmotech.api.utils.getCurrentAuthenticatedUserName
13+ import com.cosmotech.api.utils.getLocalDateNow
1214import com.cosmotech.scenariorun.WORKFLOW_TYPE_LABEL
1315import com.cosmotech.scenariorun.service.WORKFLOW_TYPE_SCENARIO_RUN
1416import com.cosmotech.scenariorun.workflow.WorkflowContextData
1517import com.cosmotech.scenariorun.workflow.WorkflowService
18+ import java.time.LocalDate
19+ import java.time.format.DateTimeFormatter
1620import org.springframework.context.event.EventListener
1721import org.springframework.scheduling.annotation.Scheduled
1822import org.springframework.stereotype.Service
@@ -24,6 +28,8 @@ private const val SERVICE_NAME = "scenariorun"
2428private const val ORGANIZATION_ID_LABEL = " organizationId"
2529private const val WORKSPACE_ID_LABEL = " workspaceId"
2630private const val SCENARIO_ID_LABEL = " scenarioId"
31+ private const val DATE_LABEL = " date"
32+ private const val USER_ID_LABEL = " userId"
2733
2834private const val DEFAULT_EMPTY_WORKFLOW_LABEL = " none"
2935private const val TOTAL_QUALIFIER = " total"
@@ -87,6 +93,20 @@ internal class ScenarioRunMetrics(
8793 labels[SCENARIO_ID_LABEL ] = scenarioId
8894 name + = " :$scenarioId "
8995 publishRunStartLabeledMetric(name, labels)
96+
97+ // By Date
98+ val pattern = " yyyy/MM/dd"
99+ LocalDate .now().format(DateTimeFormatter .ofPattern(pattern))
100+ val date = getLocalDateNow(pattern)
101+ name + = " :$date "
102+ labels[DATE_LABEL ] = date
103+ publishRunStartLabeledMetric(name, labels)
104+
105+ // By user Id
106+ val userId = getCurrentAuthenticatedUserName(csmPlatformProperties)
107+ name + = " :$userId "
108+ labels[USER_ID_LABEL ] = userId
109+ publishRunStartLabeledMetric(name, labels)
90110 }
91111
92112 private fun getRunningWorkflowsCount (): Map <WorkflowContextData ?, Int > {
0 commit comments